Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Programming Perl

by imlepid (Acolyte)
on Oct 11, 2012 at 06:53 UTC ( #998375=perlquestion: print w/replies, xml ) Need Help??

imlepid has asked for the wisdom of the Perl Monks concerning the following question:

Hi all--

I am interested in learning Perl. I have been a light Perl user for a long while but it's finally proving itself very useful for my day job (which consists of being a network admin and sys admin for systems which support/monitor the network).

Background: I, many long years ago, bought Programming Perl (Wall et al) 2nd Edition (published in 1996)! I never really did much with it other than flip though it reading a little here and there. In the mean time I have learned other programming languages like C and some Java and worked on one moderate sized (for me) Perl projects and tweaked other's Perl code when needed. I have a basic understanding of Perl. How should I get a solid understanding of Perl to assist in my job? Should I:

1) Read through the 2nd edition of Programming Perl and update my Perl through experience?

2) Read through the 2nd edition then update myself using another book or online tutorial/guide?

3) Purchase the newly released 4th edition of Programming Perl to have the most up-to-date knowledge?

4) Dispense with the dead-tree books and just learn online and on my own through experience?

5) Something not considered above?

My intermediate term goal is to become skilled enough in Perl to quickly create useful scripts to crawl through a network containing hundreds of devices and extract data from those devices. This data will likely be put into a database to be accessed via web interfaces, analyzed to create reports, and trigger alerts. There is no particular time limit; I just want to become more skilled. Given my background, goals, and resources what do you suggest?



Replies are listed 'Best First'.
Re: Programming Perl
by Athanasius (Archbishop) on Oct 11, 2012 at 07:28 UTC

    Hello imlepid,

    It seems to me that “mastering” Perl has 5 stages:

    1. The basics: simple syntax, context, sigils. I’m sure you have this down already.
    2. Perl idioms, including the standard uses of foreach, map, grep, etc.
    3. References and complex data structures.
    4. Regular expressions.
    5. Domain-specific experience with CPAN modules for using databases, etc., etc.

    For me, 3 was something of a steep learning curve (but one I eventually got over). But 4 is an ongoing journey of discovery! (For example, see my very recent post Re^2: RegEx + vs. {1,}.)

    Now, I would definitely recommend that you acquire the latest edition of the Camel Book, but “reading through” is probably not the way to go. Focused reading, targeting any weak areas in the above list, will likely be far more productive.

    And don’t neglect other sources of information: Perl documentation, especially the FAQs, comp.lang.perl.misc, and of course PerlMonks! Also don’t be afraid to challenge yourself. I can’t recommend Higher-Order Perl (free online) by Dominus highly enough in this regard.

    Just my 2¢,

    Athanasius <°(((><contra mundum

      I like your list but argue there is no idiomatic usage of foreach as idiomatic usage will prefer it be spelt for.

      Your list is interesting, because in my own case, your #2 (idioms, map, grep) came at #5, after everything else. I suppose that's because previous experience with C pointers made references easy, and experience with grep and awk did the same for regular expressions (though I agree that there's always more to learn about those). Also, you just can't do a lot of useful work without regexes, complex data structures, and CPAN.

      You can get away without map/grep and other Perlish methods like statement modifiers, though, by using a lot of loops and making your code look like C or some other language. So I tend to think of the idiomatic stuff as the sign that someone's not just capable of programming in Perl, but comfortable with it.

      I suppose everyone's list might be a little different, based on their own previous experience.

      Aaron B.
      Available for small or large Perl jobs; see my home node.

Re: Programming Perl
by nemesdani (Friar) on Oct 11, 2012 at 07:37 UTC
    Athanasius gave you excellent advice. I also suggest that you read Modern Perl by chromatic, it really helped me to develop a more Perlish style of thinking. For me, one of Perl's greatest strength lies in its idioms.

    I'm too lazy to be proud of being impatient.


      I can only endorse to that. What I think is pretty interesting is that Athanasius emphasizes the usage of idioms. The python fans always emphasize the usage of the "one-and-only-correct-idiom". I have to admit that I think that the allways stated TIMTOWTDI in Perl is a simple fact but not a perfect advice to get a good programmer in Perl.

      Start to study code on CPAN where you know that's newer code and it's well rated. You will soon get a feeling for readable code. And you will find repetitions of hopefully good idioms.

      I underrated map and grep for a long time. Look at their power.

      My last advice: I would have been happy having a good perl programmer as a mentor. I never had the oportunity. Why do I advice this: You need someone experienced who tell you what you have to think about programming for the long term. You have to comprise aspects you don't even know about when starting programming. (That's true not only for Perl.) Don't bother for throw away scripts, but over the time your own code starts to be a bundle of idioms or C&P templates. If you did it wrong you transport wrong approaches all over. Best example for that. You find many Perl documentation where the instantiation is done like

      my $obj = new Some::Class;
      which is not 100% percent correct. When you look at newer questions here in the forum you can find exactly this "wrong" idiom in questions. Why: It's Copy & Paste. That's normal. So, take care that your own C&P templates are as good as possible.

      When we are with books: Look at Higher-Order-Perl ( which is meanwhile for free. I spent money for that years ago and NEVER regret it.

      Best regards

Re: Programming Perl
by Discipulus (Abbot) on Oct 11, 2012 at 07:29 UTC
    my best read it is not present in your list: Perl Cookbook was for me and by far the more precious font of inspiration.

    Then, and cosider me still a student, because we are in 2012, search something named Modern Perl and stress your scripts with Criticism.

    Remember also that the wheel was invented yet and you can find last models of it at cpan.

    If you survived, start writing program similar to your real needs (DBI recipes and CGI manual for the mentioned 'medium' term goal) and for every problem that block you do a Super Search at perlmonks.

    If you get stucked in the learning curve, seriously consider the option to hire me... ;=) as medium level teatcher or a brick-layer coder..

    there are no rules, there are no thumbs..
Re: Programming Perl
by davido (Cardinal) on Oct 11, 2012 at 21:20 UTC

    One "way to do it":

    • Learning Perl: It sounds to me like you're probably past this point already.
    • Intermediate Perl: This may be a good choice for you; references, packages, modules, objects, testing, distribution.
    • Modern Perl: This is a nice book demonstrating a more modern philosophy toward using Perl effectively.
    • Programming Perl: I had the 2nd and 3rd editions, and wasn't sure the 4th would be worthwhile, but its sections on pattern matching (explaining more recent editions to the Perl RE sub-language), and Unicode have been highly worthwhile for me. It also covers things like security, as well as more modern tools and techniques.
    • Perl Testing: A Developer's Notebook: Perl has really embraced the testing culture, and while Intermediate Perl and the documentation for Test::More can get you headed in the right direction, this book helps to broaden ones skill-set (and tool set) for testing.
    • Higher Order Perl: This book is excellent. You probably won't want to run out and write a parser using functional techniques as the first order of business after finishing the book, but it will improve your mastery of "higher order" techniques, and this is almost certain to reflect in your code.

    There are a lot of other resources. And my list got longer than I originally intended. There are other books I really like, but didn't include, because this list alone is plenty to help you (along with your own research and practice) to get over the next hump or two, or more. :)


      Hi All--

      Thanks so much for all your advise and encouragement. I think I'll work on using my 2nd edition of Programming Perl as a jump start and reference while topping up my skills with several of the references mentioned.

      I look forward to posting more questions to the board as I learn!

        I like dead trees, so I went from Learning Perl to The Perl Cookbook to Learning Perl(4th) with a detour through Cross-Platform GUI Programminng with wxWidgets(wxPerl). I also read most of the Perl Monks posts on a daily basis to broaden my vision of what is out "there". From this I know I need to spend more time with split, join, map, grep, and regexs. Some of that stuff looks like whistling into an acoustic coupler! I like to learn from reading good code as has already been mentioned.


Re: Programming Perl
by blue_cowdawg (Monsignor) on Oct 11, 2012 at 13:46 UTC
        I am interested in learning Perl. I have been a light Perl user for a long while but it's finally proving itself very useful for my day job (which consists of being a network admin and sys admin for systems which support/monitor the network).

    Sounds to me like you're already on the path to Enlightenment.

    Rather than add to the comments folks have already made let me just say that there is no better teacher than experience. To learn a skill you need to practice the skill. If you've got a handle on the basics then the more esoteric skills will come with time and practice. If you run into a brick wall then post here in Seekers of Perl Wisdom, show us your code and you'll get a bunch of suggestions on how to get past it. Wear your thick skin though because occasionally you'll get a reply from a troll.

    If you're planning on using Perl to mine data from network devices (speaking from experience here) spend some effort learning regexes. Learn the ins and outs of Net::Telnet if that's how you are accessing the network devices.

    One strategy as well is to become well versed in creating modules. Since report writing against network data is pretty much the same broken record over and over again this is a very good application for creating "write once; use many" types of modules.

    Have fun.. Learning Perl is not a destination. It's a journey. I've been writing in Perl since 1989 or so and I'm still learning.

    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
Re: Programming Perl
by ramlight (Friar) on Oct 11, 2012 at 13:01 UTC
    When improving my coding ability in Perl I have found the following to be useful. (These same ideas have worked with other languages as well.)
    1. Read the book - you have several good recommendations already - but look to answer specific questions. Use it as a research tool. I always use a good old-fashioned book. (I guess that I'm old-fashioned myself.) It is often more helpful to get away from the screen/keyboard/mouse and relax a bit while you look something up. but...
    2. Keep perldoc bookmarked in your browser - there's no better way to quickly find the exact syntax that you want.
    3. Look at other's code; you don't have to do things the way they did, but seeing the way someone else successfully solved a problem will show you possibilities that you never thought of. Perlmonks is one of my favorite sites for this; I have learned a lot here, including new approaches to problems that were big improvements over doing things the way that I had been.
    4. Google is your friend.
    Good luck and have fun.
Re: Programming Perl
by Anonymous Monk on Oct 11, 2012 at 08:17 UTC
Re: Programming Perl
by t_rex_joe (Sexton) on Oct 12, 2012 at 18:16 UTC
    Here's a few books that will help you.
    - PERL CD Bookshelf 3.0 (searchable html)
    - MySQL and Perl for the Web (Paul DuBois)
    Mostly alot of reading CPAN modules, for SNMP/SSH.
    I have spent the last 5 years developing tools 
    you are mentioning in your question. I use mysql
    as the backend database, after I found the limits
    of flat files w/parallel processes a DB table
    was the only way to store data.
    How do you move a mountain? Once rock at a time.
Re: Programming Perl
by gok8000 (Scribe) on Oct 15, 2012 at 13:15 UTC


    I like the Camel book. Also having a problem and working around it helps a lot. So it may be early now but, as soon as possible, as an exercise, I suggest to directly try to solve your problem and search CPAN for crawl, database, DBI, DBD and other appropriate keywords.

    When you figured out which modules best fit for your problem, install them and test as much code as you can (especially from module's examples) trying to gradually approach your solution. Experience will came...

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://998375]
Front-paged by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2022-09-25 09:09 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (116 votes). Check out past polls.