

Ask HN: How did you learn Perl/Shell Scripting? - sk2code

Please suggest Links, Books &amp; Blogs (if possible).
======
kadabra9
Aside from the typical methods I used to pick up other languages (trial and
error, practicing with sample projects, banging my head against the desk), the
two most helpful resources I found were the book Modern Perl
([http://modernperlbooks.com/books/modern_perl/chapter_00.html...](http://modernperlbooks.com/books/modern_perl/chapter_00.html\)and)
a site I stumbled upon titled "Learn Perl in about 2 and a half hours"
([http://qntm.org/files/perl/perl.html](http://qntm.org/files/perl/perl.html)).

------
porlw
From the perl man page (back when it was all one page)

When I was a student I took an internship at a small software company in the
English countryside.

I was given the task of fixing 100 or so Oracle Forms (version 3, still based
on green screen technology). A field in the database was being resized from 1
to 2 characters, and I had to fix the display layouts and any related variable
declarations in the code.

The Oracle forms editor had a terrible UI, I had to navigate around the form
and drill down in each block or UI element to see the related code. There's
wasn't much of a search facility. After a bit I decided there had to be a
better way.

I started by grepping the forms files, to see where the code was referenced.
This helped, but didn't tell me where in the form the code was, so I still had
to navigate around the form looking for the places it was used.

I'm not sure why I picked up on perl, but I printed out 90-odd pages from man,
spent some time reading through, and came up with a script that did a high-
level parse of all the form files and told me which forms and code blocks
contained references to the field.

The other developers thought that this task would keep the intern distracted
for a few weeks, but I finished within a few days.

So they game me another pile of more complex changes to do. Sigh...

Other than that the Camel book is good, and the perl Cookbook.

------
Wicher
I learned shell scripting mostly from... actually using the shell as the
mothership of mostly any activity I undertake on my machines, be it at work or
at home.

The experience you gain by trying not to repeat yourself carries over into
scripting, especially if you already know regular imperative programming
constructs: you can then just look up how a specific construct is implemented
in your shell of choice.

I daily (or maybe hourly) use flow control constructs inline in shell
commands, making heavy use of I/O redirection, exit statuses, etc. I've been
doing this for over ten years now and I'm still progressing, finding more
efficient ways of doing things (currently trying to make a habit of using
ZSH's advanced globbing capabilities).

If you run a barebones keyboard-oriented desktop environment / window manager
(I use wmii) it becomes very attractive to not have to take your fingers off
the keyboard; each little efficiency increment is its own reward. But it's the
slow path.

But you asked for links, books and blogs, not my personal experience ;-)

This blog is has some OK articles on Perl/Shell:

[http://www.catonmat.net/blog/](http://www.catonmat.net/blog/)

------
runjake
FYI, Perl not PERL.

Perl -> Programming Perl & Perl Cookbook. Unsure how relevant these still are
as "Modern Perl" is the big paradigm now.

Shell -> UNIX Shell Programming by Stephen Kochan. I got around in shell
before this, but his book make me effective and competent.

~~~
sk2code
Thanks.

Yes, it is Perl.

------
Patrick_Devine
The book that really helped me out the most with Perl was "Effective Perl
Programming" (aka "Silver Ball" due to the original cover). Here's a link:
[http://www.amazon.com/Effective-Perl-Programming-
Idiomatic-D...](http://www.amazon.com/Effective-Perl-Programming-Idiomatic-
Development/dp/0321496949)

The thing I liked most about that book was that it really helped me get a
grasp on Perl idioms and start writing decent, readable Perl code. The thing
you'll find out quickly about Perl is that it can be much easier to write than
it is to read. I've written more than my fair share of Perl code which I've
let rot for a while, tried coming back and reading and been left scratching my
head.

------
jfaucett
I cant speak for Perl but when it comes to bash/shell scripting, I've got a
few links for you :)

First have look at the Linux Document Project
([http://www.tldp.org/guides.html](http://www.tldp.org/guides.html)), the Bash
Guides are really good, thats how I first got started. Also, for bash once
you've gone through the guides, download the source (apt-get source bash if
your own a debian based distro) and checkout the test suite, this will give
you a good look at the internals.

Also be sure to memorize the ins and outs of the the man command :)

Best of luck

------
ramsaysnuuhh
I learned Perl initially for sysadmin'ing from Minimal Perl
([http://www.amazon.com/Minimal-Perl-Unix-Linux-
People/dp/1932...](http://www.amazon.com/Minimal-Perl-Unix-Linux-
People/dp/1932394508)). It teach a subset of Perl necessary to use it as a
more powerful replacement for awk/sed/grep/find, primarily with one-liners. By
far the best bang/buck of any programming book I've ever read.

------
dllthomas
I learned perl from the camel and llama books, but I think there are probably
better resources these days.

I don't remember when I first started learning bash... I found some gems in
the Advanced Bash Scripting guide
([http://www.tldp.org/LDP/abs/html/](http://www.tldp.org/LDP/abs/html/)) but
that's probably not the place to start (and I've recently heard some criticism
of it).

