Kuro5hin.org: technology and culture, from the trenches
create account | help/FAQ | contact | links | search | IRC | site news
[ Everything | Diaries | Technology | Science | Culture | Politics | Media | News | Internet | Op-Ed | Fiction | Meta | MLP ]
We need your support: buy an ad | premium membership

[P]
Best Perl Book(s) for a beginner?

By starvo in Technology
Fri Feb 02, 2001 at 07:20:12 PM EST
Tags: Software (all tags)
Software

I'm starting to dive into the wonderful world of perl programming, mostly from a sysadin point of view. I've browsed through a friends copy of Learning Perl, and it seemed almost counter-intuitive for a non-programmer such as myself.

So I beg out to all Perl-Monk types.. What book/online tutorial provides a solid backgrounding/intro for a non-programmer to learn perl?


I also sifted thru a copy of "Perl for system administrators" and it seems promising.. I'm basically looking something that I can spend a few weekends reading, and then apply in many daily tasks.. (Modifying user login scripts via a template, log parsing/sorting/formatting)

Obviously, pure logic dictates that I should get my arse back in university, and take a fundamentals of programming course.... But, I've managed to self-teach all my skills up until this point, so I'm a fan of continuing down that path.

Thanks.

Sponsors

Voxel dot net
o Managed Hosting
o VoxCAST Content Delivery
o Raw Infrastructure

Login

Related Links
o Also by starvo


Display: Sort:
Best Perl Book(s) for a beginner? | 55 comments (46 topical, 9 editorial, 0 hidden)
Bah (1.85 / 7) (#1)
by Devil Ducky on Thu Feb 01, 2001 at 11:11:17 PM EST

Don't bother with going back to school for basics. Especially a university, all they care about is making their halls ivy, not teaching useful things.

I assume you've managed to do this task (learning a new language) before?

I can't really say how to learn perl as a non-programmer, but I learned from looking at code, download some programs in perl and look at the code. See what each style of command does. Then look up the specifics of the command you're interested in. I bought Programming Perl to perfect (ha!) my skills later.

In all truth you may not want to look at tear, try some cgi-bin programs instead.

Devil Ducky

Immune to the Forces of Duct Tape
Day trading at it's Funnest
Gotta disagree (3.75 / 4) (#10)
by ucblockhead on Fri Feb 02, 2001 at 12:34:05 AM EST

I have to disagree there. Universities are very important for programmers, because while you can learn languages anywhere, it is hard to find a better place to teach you the mathematical theories underlying programming. And while lots of young kids like to think those theories aren't important, not knowing them will prevent you from ever being a truly great, or even good, programmer.
-----------------------
This is k5. We're all tools - duxup
[ Parent ]
disagree with disagreement (4.00 / 2) (#25)
by Anonymous 242 on Fri Feb 02, 2001 at 10:56:24 AM EST

While I fully agree with your main sentiment, that there is far more to programming than learning the semantics of a given language, one does not have to attend a university to learn the theory of computer science.

Many individuals do find it easier to pick up computer science in a classroom. Many other individuals learn better in other environments. So much depends on a given individual and the methods by which that individual learns best.

In my mind, the largest advantage of going to a university to pick up theory is the well of professors to ask questions of. But for picking up theory, an individual with enough motivation can pick up a Knuth or Booch text and work their way through it without spending a couple grand for tuition.



[ Parent ]
In practice (3.00 / 3) (#31)
by ucblockhead on Fri Feb 02, 2001 at 12:34:33 PM EST

It is true that you can pick up Knuth or whatever on your own, and more power to anyone who does.

however...

I've only met a couple people who managed that. I've met a lot of people who mistook self-taught C programming for true programming knowledge and were consequently poor programmers.
-----------------------
This is k5. We're all tools - duxup
[ Parent ]
Start with its predacessors? (2.77 / 9) (#3)
by interiot on Thu Feb 01, 2001 at 11:19:23 PM EST

You're right, most of O'Reilly's perl books assume you know what arrays are and know why ("3" + "4") could be different from ("3" . "4"). I'll explain my path to Perl, and maybe that'll give some pointers.

My path to perl started when I borrowed a copy of O'Reilly's Unix Power Tools, a wonder wonderful book. I learned all the coolness of shells and started in on shell scripting. After a while, that seemed pretty tedius and convoluted for complicated things, and so I naturally fell into Perl.

Perl has its roots in C, shell programming, um... and several other languages. I don't know if it would be easier to learn shell programming and a bit of C first or not.

Suggested books (4.12 / 8) (#6)
by Anonymous 7324 on Thu Feb 01, 2001 at 11:40:57 PM EST

I started out with Learning Perl for Win32 systems. It's good, and has exercises at the end of each section. Shallow learning curve, and it's fun to do an exercise, and see how the author did it with 200% fewer characters. A good learning exercise.

After that, get a copy of the new Camel 3 (Programming Perl). Fleshes out a lot of stuff, talks about new stuff like Unicode support, multithreading, etc.

Conways's _Object Oriented Perl_ is also quite excellent, but if you already know OO, may still be worth skimming for the Perl-specific tips and tricks.

At that point, you essentially know enough text manipulation, network coding, etc., to be able to write whatever you want. Spending a few hours playing with modules on CPAN doesn't hurt either -- a lot of the work has already been done for you, making development very fast.

Innumeracy rampant... (3.00 / 2) (#45)
by Lulu of the Lotus-Eaters on Sat Feb 03, 2001 at 01:47:58 PM EST

Exercise:
If I write a program in 500 characters, someone who writes it in 200% fewer characters takes how many characters?

Answer:
NEGATIVE 500 characters. A various impressive programmer (even given Perl's conciseness) who can use negative length source files!

[ Parent ]
Intro no different than "Learning Perl" (4.00 / 1) (#46)
by interiot on Sat Feb 03, 2001 at 03:16:03 PM EST

Section 1.5 of "LP for Win32" is very similar to the "Learning Perl" section, and my same argument applies.

Namely that this section, while being the only introduction to basic Perl syntax, uses the words "like C" or "unlike the command shell" or "like sed and awk" or "like Java or C++" quite a lot. As such, it's probably not a book that's appropriate for first time programmers.

[ Parent ]

Perl Books (3.57 / 7) (#8)
by Smirks on Thu Feb 01, 2001 at 11:43:43 PM EST

A definite must-have perl book is the Programming Perl book, sometimes refered to as the Camel Book. I'd say that book is probably a requirement for any perl programmer. Second on my list would be the Perl Black Book which contains tons upon tons of example code. I've been sifting through Perl for System Administration for the past few days and it wasn't really what I expceted, but it does contain some good ideas that would need to be expanded upon to be used in a production environment.

[ Music Rules ]
Not for a first introduction to perl though (4.33 / 3) (#21)
by hugorune on Fri Feb 02, 2001 at 09:51:52 AM EST

I agree that the Camel book is a must-have reference book for programming in Perl, but it's hardly the best book for learning from. If starvo found Learning Perl counter-intuitive then the Camel book is probably not the best starting point. Get one of the other Perl books first, and if you find that you want to get more serious about using Perl then buy the Camel book.
--
Phil Harrison
[ Parent ]
Sysadmin and non programmer type... hmmm.. (3.16 / 6) (#9)
by hstl on Thu Feb 01, 2001 at 11:44:02 PM EST

well firstly if you want to learn the language properly the Learning Perl book is worth it. If you just want to cut/paste/modify, consider the Perl Cookbook. Secondly, I am a little sceptical of a non programming type solution for a sys admin type. While not all Sysadmins can usually code (Unix type ones anyway). In my experience its a matter of choice rather than ability, if you run a commercial system you should be able to do basic "Hello World" C etc.

O'Reilly's Perl site might not be a bad starting point, lots of links to various tutorials and information.

Anyway, good luck! Perl can save you hours if you can use it competently.


"If you want an image of the future, imagine a boot, stamping on a human face, forever." -- George Orwell, "1984"

Languages and learning programming... (3.00 / 15) (#11)
by ucblockhead on Fri Feb 02, 2001 at 12:36:49 AM EST

Like C, C++ and other pragramatic languages, Perl is a lousy language to learn how to program in.

If you want to really be a good programmer, start with a good learning language like Pascal, and only when you've mastered that move onto a "real" language. Start with the small jigsaw before you try to use the huge industrial saw.
-----------------------
This is k5. We're all tools - duxup
I disagree. (4.00 / 6) (#28)
by trhurler on Fri Feb 02, 2001 at 11:11:02 AM EST

This notion that putting training wheels on an 18 wheeler will help someone who really only wants to drive around the block has to stop. If this guy wants to learn Perl for sysadmin chores, then Pascal is a waste of his time. So are C, Java, C++, and every other language except Perl. Why? Because if he's even a half ass sysadmin, he won't need professional programming expertise to zing out onetime throwaway scripts for automating his junk work. He won't care about whether his code will be readable 20 years down the road. He won't care about whether he followed proper style. He might start caring later, and then he can learn those things, but what he wants now is something to make his life easier - suggestions that would make it harder are wrong.

However, if he DOES want to learn to program "properly," he might prefer Python to Pascal. I am not aware of anyone who can write code in both who thinks people should learn on Pascal.

--
'God dammit, your posts make me hard.' --LilDebbie

[ Parent ]
Pascal (3.00 / 3) (#32)
by ucblockhead on Fri Feb 02, 2001 at 12:38:45 PM EST

I've no experience with Python, but Pascal was specifically designed to teach computer science.

The only disadvantage I see with Pascal as a learning language is that it is compiled, not interpreted. But does Python have true pointers? That's something you've really got to know if you are going to ever get a deep understanding of how references and such in languages like Perl and Java work.
-----------------------
This is k5. We're all tools - duxup
[ Parent ]
Pascal, Python, pointers (4.00 / 2) (#34)
by trhurler on Fri Feb 02, 2001 at 02:10:03 PM EST

Python certainly has reference mechanisms. I don't think it has any regular C-style pointers, but if you want to learn those, learning to write C is probably a winning move. C pointer syntax is a bit odd, but the semantics are very clean(if a bit dangerous:), whereas the pointers present in other languages often have semantic grossness that makes learning them harder than need be. This is particularly true of Pascal, where the sheer pain involved in using a memory address as an object unto itself prevents most people from ever learning how to do it; by the time I was ready to use pointers, I knew enough about programming that I didn't really like Pascal anymore anyway.

By the way, Python was also specifically designed as a teaching language, and has the benefit of a lot more language research having been done since Pascal was created.

--
'God dammit, your posts make me hard.' --LilDebbie

[ Parent ]
ack, not perl (3.15 / 13) (#12)
by _Quinn on Fri Feb 02, 2001 at 12:43:52 AM EST

   [Disclaimer: I don't program in Perl (I do PHP or bash), but I've seen many students who do.]

   I'm really not sure that Perl is a good first language -- which is what I assume you mean by 'non-programmer'. I'm not even sure C++ is a good language, though Java would be better. Perl, IMHO, encourages poor coding (like most other scripting languages), especially in beginning programmers, because it can be so concise. So you have a little three-line program that uses some intelligent defaults, and you want to change something a little bit, it becomes more hackish as you try to preserve the ease of the initial implementation and eventually become the canonical (or so it seems to me) byzantine mess.

   The language that sounds the most interesting to me (from a presentation in the 2001 Jan Dr. Dobb's Journal) is 'ruby', at www.ruby-lang.org; since you like self-teaching, the lack of english-language books shouldn't bother you much.

-_Quinn
Reality Maintenance Group, Silver City Construction Co., Ltd.
www.rubycentral.com (3.50 / 2) (#18)
by lmnop on Fri Feb 02, 2001 at 08:52:11 AM EST

There's an english language book on ruby at: http://www.pragmaticprogrammer.com/ruby/index.html

There's also some ruby info at www.rubycentral.com

I haven't read the book yet so I can't comment on it.

-lmnop


"If all else fails, immortality can always be assured by spectacular error." -- John Kenneth Galbraith
[ Parent ]
Learning Perl in 21 Days (3.50 / 8) (#14)
by Greener on Fri Feb 02, 2001 at 01:09:55 AM EST

The book I learnt perl from was Learning Perl in 21 Days from Sams Publishing. It started right from the basics and explains things well enough for the beginner but also gets into some more in-depth stuff like modules, CGI and Object Oriented Programming. I polished it off in a couple days not so much learning everything about perl as getting an idea of just what perl could do and where to check back in the book to find the information I needed when I had to write my first few scripts.

I think I was parsing, sorting and formatting log files in about a week or two. It tool a while to get my head around the REGEX section though having never seen anything like it before but once I did I was amazed at how qick and easy string manipulation was after having to do it in C at school.

I don't mean to sell O'Reilly short but this book was kicking around the office where I did my co-op and was my first oppertunity to learn/use a language I was interested in for a while. A couple months later I bought O'Reilly's Perl CD Bookshelf.

Sam's in 21 day book. (3.00 / 1) (#15)
by chuqui on Fri Feb 02, 2001 at 01:28:32 AM EST

I'll second the recco for the Sam's "perl in 21 days" book. It's by far the more dogeared of my perl books, and the one I usually look at first for an answer. Not full of the trivia about perl as the Camel book, but if you're starting oyu, you want to avoid the trivia.


-- Chuq Von Rospach, Internet Gnome <http://www.chuqui.com> <kuro@chuqui.com> "The first rule of holes: If you are in one, stop digging"
[ Parent ]
Sams and a few others not mentioned (3.00 / 1) (#41)
by ksm on Sat Feb 03, 2001 at 09:20:31 AM EST

The Perl books that got me on the path the most: * Sam's Learn Perl in 21 Days * Peachpit Press's Perl and CGI for the World Wide Web * O'Reilly's Perl Cookbook (as a reference/example guide only!)

[ Parent ]
Yeah, Sams seems to be the way to go... (3.00 / 6) (#16)
by lucas on Fri Feb 02, 2001 at 02:08:04 AM EST

I used the Sams "Perl in 21 Days" book... It was extremely useful and intriguing; the examples are superb.

If you're going to do web programming, try learning PHP instead. I've found it to be much easier to deploy and use... and it is very similar to Perl in syntax. I did it backwards and learned how to filter everything through the cgi interface to Perl only to be introduced to PHP later on and find it to be much more suited for web stuff.

I would suggest Perl to beginners just because it takes a lot of the tedious stuff out of programming and has a lot of UNIX-isms that can be applied to UNIX in general.

This is probably going to be controversial, but I would also say to steer clear of O'reilly & Associates. In the early 90's, Larry Wall published the eloquently written "first camel" book which allowed, among other things, to get an idea of his rationale in designing the language. With subsequent revisions, the quality has become scatterbrained and illogically laid out. Larry's witty "wallisms" were replaced by generic commentary. My general view is that ORA is getting sloppy with their books and rushing them to press too quickly (with too many varieties), as the past 3 books I have purchased from them have been incredibly sub-par and badly written/laid-out.

In terms of editing, I was playing it old-school and using vi until I found the Nirvana Editor (nedit) which seems to be a really clean, fast editor with great Perl/PHP syntax highlighting. I'm interested to hear what everyone else uses to edit code (under X and Linux or *BSD), since I'm always up for switching to something new.



Camel for Perl, but... (3.50 / 4) (#17)
by pak21 on Fri Feb 02, 2001 at 07:57:07 AM EST

If you want to learn Perl, the answer is, as always, Camel (aka Programming Perl). However, if Learning Perl was going over your head to some extent, I'm not quite sure what to recommend - I picked up Perl pretty quickly once I started using it (and had an itch or two to scratch)... but then I'd been happily hacking away in C for a good few years (no formal training, though. May explain why my code is so awful :-)). Which languages (if any) do you know/have played around with, etc?



Fewer Humps! (4.00 / 1) (#24)
by j on Fri Feb 02, 2001 at 10:45:59 AM EST

If you want to learn Perl, the answer is, as always, Camel(aka Programming Perl).
For absolute beginners, I would suggest to get rid of the hump and go with the LLama (aka 'Learning Perl').
Llamas are closely related to dromedaries, aren't they?
Anyway: I would go with one of the O'Reilly books - just because they were written by people that are very close to the topic. Of course, they both have their problems: Where the Camel gets lost in technical details too early, the Llama is a bit too silly for my taste.
But if you are completely new to programming, you'll probably rather deal with variable names that are consistently named after 'Flintstones' characters than with discussions of Perl internals preceeding any useful programming information.

[ Parent ]
Learning Perl not appropriate (3.75 / 4) (#35)
by interiot on Fri Feb 02, 2001 at 03:25:20 PM EST

The first mention of syntax in Learning Perl occurs in section 1.4 and 1.5. It's clear that the book was written for people who have already had exposure to other programming environments (other than simply using an abundance of terms that wouldn't be clear to a layman).
    Perl is mostly a free-format language like C - whitespace between tokens (elements of the program, like print or +) is optional, unless two tokens put together can be mistaken for another token, in which case whitespace of some kind is mandatory. (Whitespace consists of spaces, tabs, newlines, returns, or formfeeds.) There are a few constructs that require a certain kind of whitespace in a certain place, but they'll be pointed out when we get to them. You can assume that the kind and amount of whitespace between tokens is otherwise arbitrary.

    Although nearly any Perl program can be written all on one line, typically a Perl program is indented much like a C program, with nested parts of statements indented more than the surrounding parts. You'll see plenty of examples showing a typical indentation style throughout this book.

    Just like a shell script, a Perl program consists of all of the Perl statements of the file taken collectively as one big routine to execute. There's no concept of a "main" routine as in C.

    Perl comments are like (modern) shell comments. Anything from an unquoted pound sign (#) to the end of the line is a comment. There are no C-like multiline comments.

    Unlike most shells (but like awk and sed ), the Perl interpreter completely parses and compiles the program into an internal format before executing any of it. This means that you can never get a syntax error from the program once the program has started, and that the whitespace and comments simply disappear and won't slow the program down. This compilation phase ensures the rapid execution of Perl operations once it is started, and it provides additional motivation for dropping C as a systems utility language merely on the grounds that C is compiled.

There's no mention of things that would be useful to non-programmers, such as why the following don't work, or don't work as expected:

    while ($flag == 0);
    {
        print hello world\n;
        print 1 . 2;
    print "array value is $array[1.4]"; }

Most intro to programming classes start off with things like... what strings are and why quotes are needed; the difference between a variable name and a quoted string containing the same word; how the assignment operator differs from the mathematical = operator (eg. in the context of mathematics, x = x + 1 would be an invalid statement).

O'Reilly books are wonderful, but they're not written for the newbie audience.

[ Parent ]

Well (4.00 / 1) (#37)
by Anonymous 7324 on Fri Feb 02, 2001 at 05:39:37 PM EST

there's always a learning curve, but you have to start from somewhere. Coming from dabbling in QuickBasic for DOS to writing God-awful C++ code that really screamed to be written in Perl (though I didn't know this at the time), learning Perl was about right, if a bit slow.

Learning Perl assumes that you know the basics of an imperative language, and that you've dabbled in either Pascal, C, or a look-alike (Shell, Quickbasic, etc.) There are advantages to previous knowledge, but you end up carrying a lot of excess baggage and writing C code in Perl, which is silly. (Initializing new variables? Nahhh...)

The biggest problem that I saw with Learning Perl for Win32 as I look over my copy again right now, is not the learning curve, but the lack of information about references (pointers to the rest of the world), and of course, anonymous hashes and associative arrays. This is _really bad_, because a beginning programmer who's done C will wonder where his pointers are, and the beginning programmer who hasn't done C-like languages will still wonder how to construct even somewhat complicated data structions.

Still, a good intro to Perl, and something that you can do, with all the examples, in about 15 hours or so, from my experience.

[ Parent ]
Damion Conway's Object Oriented Perl (3.85 / 7) (#19)
by Anonymous 242 on Fri Feb 02, 2001 at 08:58:37 AM EST

I pretty much taught myself Perl from HOWTOs, FAQs, man pages and the incidental aid of books from the library. I even bought a couple books to learn from.

A couple years later, I worked through Dr. Damion Conway's Object Oriented Perl and I started really understanding the way Perl worked. Despite the title, OOP teaches non OO programming quite well. It shows how to use the various (mis)features of using Perl to do some very complicated stuff.

Read the customer reviews at Amazon. Find the best price at BookFinder.



I vote this up because (3.88 / 9) (#23)
by mami on Fri Feb 02, 2001 at 10:42:35 AM EST

The first time I intended to learn Perl (1997) I contacted clpm and their answers really .... me off. Why ? Because I got tons of different answers and caused long threads of moral index finger pointing about how to become a programmer and what a programmer is.

There are the "learn programming first"-lers (CS curriculum the minimum prerequisite), don't start with Perl, start with language xyz (gosh no, start with language uvw, how could you, it's language abc - darn no, never that one, how can you misguide an innocent newbie like that, you need to learn Math first), then there are the "do-it-your-selfers", who become a programmer in three weeks using the thick books (SAMS, QUE) with a lot of black ink (hey, do they think I am an idiot ?), then there are the serious masochistic studiosi who actually work themselves through the real material and almost never answer those questions, because they know it's irrelevant. I like those. I think they read the docs, Programming Perl and whatever they need at a given time.

Then there are some few inspirational people, they don't say much, but do amazing things. If you happen to know how they got there and where they came from you know that it's all up to you.

I don't know, if I start reading a text book, it takes me at most thirty minutes to know if it's what I need and what I can understand. Learning Perl never impressed me as much as the many recommendations of the book let me believe. I always read several books at once til I find what I need to comprehend anyway.

Perl books for non-programmers (4.00 / 1) (#38)
by mami on Fri Feb 02, 2001 at 11:20:00 PM EST

I answer to my own post. I am in the middle of starting all over to learn Perl and am a neither a programmer nor a Unix system administrator. So, that's a worst case szenario.

First beginner's Perl books (I use them all) :

   Elements of Programming with Perl, Andrew L. Johnson
   Beginning Perl, Simon Cozens
   Algorithms with Perl, Jon Orwant, J. Hietaniemi

I think one should always have these books:

   Programming Perl, Larry Wall
   Perl Cookbook, Tom Christiansen
   Perl in a Nutshell,

And one should read

   Object Oriented Perl, Damian Conway

Other than those, one needs to read the Perl docs and source code and just work on a specific project. I think also one needs to know C. My experience is that it is not taught anywhere anymore aside from CS or Electrical Engineering dept.

Eventually others dependent on what one is doing and interested in or need. Some Perl books are now dedicated to specific subjects, like System Admin, Debugging, Cross Platform Perl Programming, etc.

[ Parent ]
Answer the question... (3.83 / 12) (#26)
by pb on Fri Feb 02, 2001 at 10:57:57 AM EST

I see a lot of posts that say "Why are you learning Perl?" here. Well, maybe he has a reason!

Perl is a great language for scripting tasks for system administration, which seems to be what he wants to do. Remember, people, we aren't trying to build a beautiful software system here, and we all have different tastes.

For instance, I find both the Java syntax *and* the implementation to be pretty ugly compared to Perl. Java is verbose, and in the design process it seems that they found a list of key language features and broke them all. Perl, on the other hand, is very flexible in its syntax, and supports many features I'd want in a language, and many others that I hope never to have to use. :)

...and it isn't a bad first programming language, either. The trick is moving away from the BASIC-style programming, and up into using the higher-level constructs properly. It's possible to write well-documented perl, or object-oriented perl, but most of all it lets you get your work done and it stays out of your way.

So leave the language out of it, and suggest a book! I learned perl from "Programming in Perl" and "The Perl Cookbook", because "Learning Perl" didn't have enough direction in it for me. However, I wouldn't suggest this route for beginners, either. I bet there's a tutorial on the web somewhere, though...
---
"See what the drooling, ravening, flesh-eating hordes^W^W^W^WKuro5hin.org readers have to say."
-- pwhysall

Best books (1.92 / 13) (#29)
by wiredog on Fri Feb 02, 2001 at 11:11:29 AM EST

Perl for system administrators if you're not a programmer. But, you might want to try Python. Much easier to learn on, and it does the same sort of stuff as perl.

The idea of a global village is wrong, it's more like a gazillion pub bars.
Phage

Re:Best Books (2.00 / 2) (#44)
by starvo on Sat Feb 03, 2001 at 12:55:08 PM EST

They Said: Perl for system administrators if you're not a programmer. But, you might want to try Python. Much easier to learn on, and it does the same sort of stuff as perl.

I actually seem to grok python a bit better than Perl.. But I need to be able to whip up scripts that others can eventually take, and interpret/modify.. And perl seems to be the common ground between me, and my fellow admins.

Actually, I just got a copy of the llama/camel/cookebook as of yesterday.. so cheers to me spending the rest of this weekend reading them.. And thanks to everyone for the great advice.. the Cookbook seems to be VERY much exactly what I am looking for.. :-)


=---------------------------------- -My views are mine, -and not that of my employer -unBOLT the email addry to mail me =----------------------------------
[ Parent ]

Learn Java (1.16 / 25) (#30)
by delmoi on Fri Feb 02, 2001 at 11:53:09 AM EST

It's better!
--
"'argumentation' is not a word, idiot." -- thelizman
Learning Perl & the Perl Cookbook (3.66 / 6) (#33)
by trust_no_one on Fri Feb 02, 2001 at 01:33:39 PM EST

When I first approached Perl I started with the 2nd Edition of the Camel (Programming Perl). It confused the heck out of me. Definitely not the best introduction. I then picked up the second edition of the Learning Perl (the llama). The llama was a very kind and gentle introduction to the eccentricities of Perl. It's mostly geared toward Perl 4 type features, without much in the way of new functionality provided in Perl 5.

But the book I refer to all the time now is the Perl Cookbook. Whenever I'm about to whip up a script I flip through the Cookbook to see if I'm about to reinvent the wheel (badly). Most times the cookbook will point out a module that already implements the functionality I'm looking for.

I think with the above two books, and a new version of the Camel, you should be able to accomplish almost anything you need to do with Perl.

--
I used to be disgusted, now I try to be amused

I second that (4.00 / 1) (#39)
by greenplato on Sat Feb 03, 2001 at 02:11:16 AM EST

This describes my experience exactly. I borrowed Programming Perl (the camel book, 2nd edition) from a friend and found reading it to be something like swimming up current through honey. It was too dense and eccentric for me having no real programming experience other than little bash scripts.

With that bad taste in my mouth I stayed away from perl for a while. My school work was in C and Java, so in the meanwhile I learned some real programming skills (whatever that means).

Recently I was trying to do some web programming for a freind's site and was having a good time with PHP. But soon PHP started to feel a little confining, so I decided to try perl again.

I got a copy of Learning Perl (llama book) and it read like butter. I zipped through it in a few days feeling informed and confident. I picked up The Perl Cookbook which I now use as a primary "how to get things done" guide. Sites like perlmonks and use.perl.org are also great references at this point. But I still find value in the camel book when I need to know how perl works under the hood.

At the top of my wishlist now is Conway's Object Oriented Perl.

Good luck.

[ Parent ]

A natural language for beginners (4.33 / 3) (#40)
by mdavids on Sat Feb 03, 2001 at 06:58:11 AM EST

I'm surprised at the people who have suggested that Perl isn't a good language for beginners. It seems to be the kind of language that is counter-intuitive to a computer science graduate. For the rest of us, I think it's actually easier, because it's flexibility is something like what we're used to in spoken language. Or something like that with which we are accustomed. Or similar to what we are familiar with. Or kinda like what we already know.

And as Larry Wall says, the learning curve is shallow. You don't have to learn the whole language to do useful things with it. In fact there's no shame in using Perl as an infant uses English. If you can get your meaning across (ie. your program works), it doesn't really matter how inelegant, idiosyncratic, or even comical, your personal dialect is. Unless of course someone else has to step in and maintain your code, which doesn't bear thinking about, so most people just don't think about it.

Mind you, you're in an awkward spot as a sysadmin. I learned Perl with no programming experience (unless you count playing with BASIC on a Microbee 16k in my lunch breaks at high school; adolescent nerds had it tough in my day), but for my first few years with Perl I was only doing CGI. All I had to do was master getting data in and out of a database, then spitting it out through STDOUT. You'll probably be wanting to mess around with pipes, sockets, processes, system calls and all the other UNIX sorcery.

So I'd recommend The Perl Cookbook, plus either the Camel or Llama book, plus a quick reference book (at the risk of sounding like an O'Reilly salesman, perhaps Perl in a Nutshell). No, I don't consider perldoc perlfunc to be a quick reference.

I found The Perl Cookbook was worth the substantial expense, if only for the recipe on non-blocking I/O, something for which I'd been searching for ages in vain on the web. The book should really be GPL'd and on the net somewhere. Tom's Object Oriented Tutorial (perldoc perltoot) is also essential reading once you've mastered the core language. It'll help you understand what you're doing when you're using modules.

Most of the time, you'll probably be cutting-and pasting blocks of code from Tom's recipies and elsewhere without knowing how they work. Understanding will come gradually, and on the fifth re-reading of the Llama book, most of it will make perfect sense. Of course, by then you'll be wanting to move onto Advanced Perl Programming, so you'll still feel dumb.



perl books, a review (5.00 / 5) (#42)
by kellan on Sat Feb 03, 2001 at 10:26:22 AM EST

i started my programming life with a version of Learning Perl aka the Llama book, and a beat up old copy of "Teach Yourself C", between the 2 of them I got all the basic concepts.

when i moved on to programming perl proffessionally I bought Programming in Perl aka the Camel book, which is the bible of perl programming.

when I wanted to become a better perl programmer I picked up Advanced Perl Programming which made me a better programmer, and a better perl programmer, but which is now slightly out of date.

Shortly thereafter I acquired the essential and fascinating Mastering Regular Expressions aka Wise Old Owl. This really took my understanding regular expressions and what they could to a whole new level, and allowed me to more easily read the code of the masters.

The Cookbook might have been a good place to learn, but by the time it came out, I was no longer a neophyte perl programmer. Still it is a very useful refrence book, partially because it takes a very practical approach to its solutions. If there is a CPAN module to do the work, it tells you, rather then trying to answer all questions in pure Perl.

Writing Apache Modules and Mastering Algorithms in Perl have both been very helpful.

Programming the Perl DBI, and Programming Web Graphics with Perl & GNU Software suck! I was shocked when I bought the Web Graphics book, it was so bad it permanently rattled my confidence in O'Reilly. I'm much more careful about which O'Reilly books I buy now.

As I was starting move from wanting to be a perl hacker, to be a system architect who designed elegant, "correct", applications Object Oriented Perl from Damian Conway is an absolutely incredible, blow your brain good book. I started buying Manning books after reading it.(they are mixed in quality) Besides you should buy this book just to support Damian, the world needs more people like him.

kellan

one more! (4.00 / 1) (#43)
by kellan on Sat Feb 03, 2001 at 10:36:31 AM EST

also Effective Perl is an excellent refrence, kind of like the Cookbook (it predates it) but slimmer, and more readable. Its quest is to get you thinking in idiomatic perl. This is where I learned some neat regex tricks, and most importantly about the Benchmark module!

kellan

[ Parent ]

Second that... (none / 0) (#51)
by Behemoth on Sun Feb 04, 2001 at 03:41:01 PM EST

Effective Perl Programming is great (one you're mostly up to speed... :) I agree it's Cookbook-ish, but on a lower level, i think. It contains possibly the most lucid explanation of my vs. local declarations i've ever seen.

Learned something new every time I picked it up.

[ Parent ]
0 and 1: My Two Bits (3.00 / 2) (#47)
by swr on Sat Feb 03, 2001 at 08:21:52 PM EST

Others have suggested that perl is not a good first language. I'm inclined to agree. It's rather cryptic if you aren't already familiar with it, and the weak type checking assumes that you know what you are doing ($x vs @x vs $x[$i] vs %x vs $x{$i} (not to mention \$x vs \@x vs $$x vs...)). The automatic type conversion bites everyone at first, and although it's a nice convenience once you understand it, you shouldn't have to wrestle with that at the same time as you are learning basic programming concepts.

If you want to learn programming in general, I'd suggest learning the basics of C. C is probably the single most influential programming language - lots of languages (including perl) inherit some of its syntax. Learn the basics of C until you understand the syntax, the basic data types, and the difference between &foo and *foo. But by the time you get to malloc()/free() and/or typedef/structs/unions and/or string manipulation it's probably time to move on.

If you just want to learn to automate simple computing tasks (I'm of the opinion that this ranks up there with the three Rs) then probably the best place to start is with good old shell scripts. If you've been using a unix shell for any amount of time then by now you are already familiar with at least some of the syntax, and much of the API (in shell script the standard unix commands effectively constitute an API). Learn ksh (or bash or zsh - the latter has lots of conveniences (like this: for letter (a b c) { echo $letter } )). Don't bother learning csh as nobody uses it for scripting - there's even a doc out there called "csh programming considered harmful". If you're in MS-land you probably don't have a decent command-line environment, in which case you'll probably have to just dive in to perl.

When you are ready to learn Perl, there are a number of Perl tutorials on the web. Google search: perl tutorial is a good place to start. On-line tutorials are how I learned Perl five or six years ago, although I had some C and shell script experience to draw on. YMMV

Once you've learned Perl, a handy Perl reference is available on-line for sending to your printer.



0 and 1: My Two Bits (2.00 / 1) (#48)
by swr on Sat Feb 03, 2001 at 09:04:45 PM EST

Others have suggested that perl is not a good first language. I'm inclined to agree. It's rather cryptic if you aren't already familiar with it, and the weak type checking assumes that you know what you are doing ($x vs @x vs $x[$i] vs %x vs $x{$i} (not to mention \$x vs \@x vs $$x vs...)). The automatic type conversion bites everyone at first, and although it's a nice convenience once you understand it, you shouldn't have to wrestle with that at the same time as you are learning basic programming concepts.

If you want to learn programming in general, I'd suggest learning the basics of C. C is probably the single most influential programming language - lots of languages (including perl) inherit some of its syntax. Learn the basics of C until you understand the syntax, the basic data types, and the difference between &foo and *foo. But by the time you get to malloc()/free() and/or typedef/structs/unions and/or string manipulation it's probably time to move on.

If you just want to learn to automate simple computing tasks (I'm of the opinion that this ranks up there with the three Rs) then probably the best place to start is with good old shell scripts. If you've been using a unix shell for any amount of time then by now you are already familiar with at least some of the syntax, and much of the API (in shell script the standard unix commands effectively constitute an API). Learn ksh (or bash or zsh - the latter has lots of conveniences (like this: for letter (a b c) { echo $letter } )). Don't bother learning csh as nobody uses it for scripting - there's even a doc out there called "csh programming considered harmful". If you're in MS-land you probably don't have a decent command-line environment, in which case you'll probably have to just dive in to perl.

When you are ready to learn Perl, there are a number of Perl tutorials on the web. Google search: perl tutorial is a good place to start. On-line tutorials are how I learned Perl five or six years ago, although I had some C and shell script experience to draw on. YMMV

Once you've learned Perl, a handy Perl reference is available on-line for sending to your printer.



Mozilla sucks sometimes (none / 0) (#49)
by swr on Sat Feb 03, 2001 at 09:08:33 PM EST

Blah, that's the second time I've done that. The problem is, Mozilla wants to repost form data even when just using the "back" button. It always pops up a "Result of a post request, yada yada" dialog and asks if you want to repost, but doesn't tell you what it is you are reposting to (I thought it was a search query (wrong window)).



[ Parent ]
here's my advice... (2.00 / 1) (#50)
by joto on Sat Feb 03, 2001 at 10:43:37 PM EST

I've browsed through a friends copy of Learning Perl, and it seemed almost counter-intuitive for a non-programmer such as myself.

In that case, you should probably start by learning to program first. Learning Perl is a very simple textbook on Perl, but is probably not the ideal resource for someone who doesn't even know how to program! I am not sure if there are any Perl-books designed for non-programmers, maybe some "dummies", "teach yourself in 21 days", or simililar book will help you, but in my opinion you would be better suited with a book designed for use in an introductory programming course in a university.

Once you know how to program, I think you will find "learning Perl" comprehensible. I am not aware of any Perl books designed for teaching people how to program, so you may have to take a detour and learn some other language first.

Which language you choose will not matter much in the end, as it is the general programming concepts that is important, and not specific language details. Since you seem to be doing this on your own, and not participating in a class, it would be an advantage to choose a widely used language, as it will probably be much easier to get help that way.

While some less used languages, such as Scheme, ML, Haskell, Prolog and others are perfectly suited for teaching introductory programming classes, it might be harder to keep yourself inspired if you feel you are the only one in the world working with that language (that will not be true, of course, but it can feel that way). On the other hand, people actually using (as opposed to learning) them are often very knowledgeable of computer science.

I recommend you start with a good text-book on Java, as it is a relatively clean language, that happens to be pretty popular for the time being. And it also has good standardized class libraries for GUI-programming and other stuff that can be inspiring to use.

Another good choice would be C, because if you want to do programming, at some point in time you will probably have to learn it anyway. But C is a bit more difficult to learn than Java, so it's perhaps not the best choice.

I can also recommend Python, which has some excellent introductory tutorials aimed at non-programmers, a relatively clean syntax, and otherwise many of the same features as Perl. On the other hand, I don't know of any books aimed at complete beginners in Python either, but it might be easier anyway.

Delphi might also be a good option if you are working on Windows, but since you ask about Perl, you are probably not?

Perl and C++ is examples of programming languages that both have lots of good features. However, both languages are so big and complex that a total beginner will become overloaded with details, so they are probably not ideal choices.

Note that there are many crappy textbooks, as well as some good ones. Since I haven't read many introductory textbooks lately, I will not recommend any, but you will find recommendations many places on the web (such as amazon.com customer reviews). The best way to find out is perhaps to go to a university bookstore and ask (not nessecary those who work there, but perhaps the guy with the glasses looking out obscure books who has been there for hours). Make sure that you get a book meant for people with no prior programming knowledge, not just an introductory tutorial for people wanting to learn a new language.

Perl by Example, ISBN 0131228390 (none / 0) (#52)
by jonr on Mon Feb 05, 2001 at 03:50:30 AM EST

"Perl by Example" by Ellie Quigley, it gives you a real warm fuzzy feeling, and you has some good examples.

Second that... (none / 0) (#54)
by TrinityTestSite on Mon Feb 05, 2001 at 04:03:05 PM EST

I second that recommendation. I have that book and use it.

For myself, learning Perl was (still is?) something of a challenge. While true that one can write functioning scripts after a short while, I would not consider it to have a shallow learning curve precisely because of the language construction. With so many ways of saying the same thing, it tends to be confusing sometimes to read code (with understanding).

Personally, I found that PHP allowed me to do the same things in a more straight-forward manner. But that is just personal preference.

clusterfuck is the word that comes to mind
[ Parent ]

Reading is not enough (none / 0) (#53)
by Remmis on Mon Feb 05, 2001 at 05:20:07 AM EST

I submit that you can not, repeat NOT, learn how to program by simply reading a book. You can, however, learn if you write programs as you read through the book. I discovered quite early on, that after reading a few chapters and thinking back, I really had no idea what I had just read. It has become almost second nature now to put anything new being introduced to the test while reading. If this isn't your problem at all then ignore me( :), but the way you described it as "spend a few weekends reading" doesnt seem conducive to learning. If you truly have no background in programming then even moreso. Sit down in front of a computer with the book in your lap and try to write some simple programs after each chapter(even if there are no exercises). We can argue about which language you should actually try to learn first until we're blue in the face but I think if you put your mind to it, "Learning Perl" should work out just fine.

Once again, if this doesnt apply at all, forget you read it :P




Go and buy Elements of Programming with Perl (none / 0) (#55)
by armbothism on Mon Feb 05, 2001 at 06:51:51 PM EST

This is a good book for learning to program and to learn perl as it uses perl as its language to teach programming concepts!.

I learnt perl through the llama book, I was fairly new to programming. But would heartily recommend Elements of Programming with Perl.


Example chapters are available, so go read chapter one online. It covers more ground than the Llama book, seeing as its focus is to teach programming as well as perl.

cheers,

armbothism.

-- Whoops!
Best Perl Book(s) for a beginner? | 55 comments (46 topical, 9 editorial, 0 hidden)
Display: Sort:

kuro5hin.org

[XML]
All trademarks and copyrights on this page are owned by their respective companies. The Rest 2000 - Present Kuro5hin.org Inc.
See our legalese page for copyright policies. Please also read our Privacy Policy.
Kuro5hin.org is powered by Free Software, including Apache, Perl, and Linux, The Scoop Engine that runs this site is freely available, under the terms of the GPL.
Need some help? Email help@kuro5hin.org.
My heart's the long stairs.

Powered by Scoop create account | help/FAQ | mission | links | search | IRC | YOU choose the stories!