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

Hi,

I've been dabbling with Perl on and off since a while. Managed to write some decent scripts. After a two year gap, am looking forward to give it another try.

I started with Learning Perl Book, as many here would have started, and by the time I finished about 70% of it, was able to write scripts that helped automate monitoring stuff. Of course I have forgotten most of the syntax etc, so wondering if its better to start once again with "Learning Perl", or directly jump to Intermediate Perl and then, as and when need arises, "refill" the gap by going back to Learning Perl? I've heard that it's the next book to go for after Learning Perl.

Wanted to see how much I still remember. So quickly whipped up the following.

#!/usr/bin/perl use warnings; use strict; my @numbers = (1..100); my @tripled = map {$_ *3} @numbers; print "tripled -> $_\t" foreach (@tripled); print "\n"; my @ends_with_2 = grep {$_ =~ /2$/} @numbers; print "Ends With 2 -> $_\t" foreach (@ends_with_2); my %somehash = ( "firstname" => "first", "secondname" => "middle", "lastname" => "surname", ); print "\n"; foreach my $thing (sort keys %somehash) { print "Key$thing, Value is $somehash{$thing}\n"; }

And it worked.

perl test.pl tripled -> 3 tripled -> 6 tripled -> 9 tripled -> 12 triple +d -> 15 tripled -> 18 tripled -> 21 tripled -> 24 tripled -> +27 tripled -> 30 tripled -> 33 trip led -> 36 tripled -> 39 tripled -> 42 tripled -> 45 triple +d -> 48 tripled -> 51 tripled -> 54 tripled -> 57 tripled -> +60 tripled -> 63 tripled -> 66 trip led -> 69 tripled -> 72 tripled -> 75 tripled -> 78 triple +d -> 81 tripled -> 84 tripled -> 87 tripled -> 90 tripled -> +93 tripled -> 96 tripled -> 99 trip led -> 102 tripled -> 105 tripled -> 108 tripled -> 111 triple +d -> 114 tripled -> 117 tripled -> 120 tripled -> 123 tripled -> +126 tripled -> 129 tripled -> 132 trip led -> 135 tripled -> 138 tripled -> 141 tripled -> 144 triple +d -> 147 tripled -> 150 tripled -> 153 tripled -> 156 tripled -> +159 tripled -> 162 tripled -> 165 trip led -> 168 tripled -> 171 tripled -> 174 tripled -> 177 triple +d -> 180 tripled -> 183 tripled -> 186 tripled -> 189 tripled -> +192 tripled -> 195 tripled -> 198 trip led -> 201 tripled -> 204 tripled -> 207 tripled -> 210 triple +d -> 213 tripled -> 216 tripled -> 219 tripled -> 222 tripled -> +225 tripled -> 228 tripled -> 231 trip led -> 234 tripled -> 237 tripled -> 240 tripled -> 243 triple +d -> 246 tripled -> 249 tripled -> 252 tripled -> 255 tripled -> +258 tripled -> 261 tripled -> 264 trip led -> 267 tripled -> 270 tripled -> 273 tripled -> 276 triple +d -> 279 tripled -> 282 tripled -> 285 tripled -> 288 tripled -> +291 tripled -> 294 tripled -> 297 trip led -> 300 Ends With 2 -> 2 Ends With 2 -> 12 Ends With 2 -> 22 + Ends With 2 -> 32 Ends With 2 -> 42 Ends With 2 -> 52 + Ends With 2 -> 62 Ends With 2 -> 72 Ends With 2 -> 82 Ends With 2 -> 92 Key is firstname, Value is first Key is lastname, Value is surname Key is secondname, Value is middle

I remembered Map and Grep, but did not remember the syntax. A quick look at the perldocs refreshed it and it sort of came back to me. So question is, should I jump in to reading (and trying out exercises) in Intermediate Perl, or should I go back to Learning Perl and start all over again?

Replies are listed 'Best First'.
Re: Re learning Perl
by hdb (Monsignor) on Mar 02, 2015 at 21:37 UTC

      Hi hdb

      Man that was a fast reply. Thanks. I thought Modern Perl to be an advanced book. So never thought about it.

        "Modern Perl" starts from the basics and gradually goes into more advanced topics. It's great as a reminder and a way to learn more about the language.
Re: Re learning Perl
by Laurent_R (Canon) on Mar 02, 2015 at 23:36 UTC
    Given the code you have shown, you certainly don't need to to go through the early chapters of Learning Perl, you obviously master the key basic aspects of the language (or know to get back to them through the documentation). But since you implied, if I understood correctly, that you covered only 70% of that book, it would probably be worth go back to the 30% left (or perhaps going back a little bit, say the last 40%) before moving to Intermediate Perl.

    Chromatic's Modern Perl has also been suggested. It is an excellent book, and I know it in a fairly detailed fashion for having been the translation and technical editor of its French translation in the last months. IMHO, it is likely to get you faster to Perl fluency than Learning Perl and Intermediate Perl. You asked whether it is for beginners. Well, yes and no. Modern Perl covers all the basic material and much more, but it is not really geared toward pure or very early beginner because, despite all the good that I think about this book, it has in my mind one defect: it is not really pedagogically organized for beginners. (BTW, for pure or early beginners, Beginning Perl, by Curtis "Ovid" Poe, is in my view another very good choice.)

    Just one example on Modern Perl's problem (only for pure beginners, IMHO): a relatively complex subject such as dealing with Unicode is presented 25 pages into the book, while elementary things such as conditionals, looping directives and control, scalar and array assignments and other very basic concepts are explained much later. So, in my view, this is really not a book for a pure beginner, but more a book to really improve your Perl when you already know quite a bit of it. But since you are not a pure beginner, this might very well fit exactly your needs.

    Having said that, I would say that the best would be for you to use both. Each author has a different viewpoint and, although the Perl community has built a common corpus of best practices, reading different authors enrich your knowledge.

    Je suis Charlie.
Re: Re learning Perl
by AppleFritter (Vicar) on Mar 02, 2015 at 22:17 UTC
    Sounds to me like you'd be better off with Intermediate Perl (or another book entirely), seeing as how you're already well-familiar with the basics and able to read up quickly on what the missing bits using perldoc, but that said -- why choose? Why not read both at the same time and see which one provides more value? If you find either doesn't serve a purpose, just shelve it again.
Re: Re learning Perl
by dmitri (Priest) on Mar 03, 2015 at 04:50 UTC
    Are you new to Perl or new to programming? If you have programmed before and just want to pick up Perl, forget Intermediate Perl (somehow we had all managed to learn Perl before this title was introduced). Instead, get these:

    • Programming Perl
    • Object-Oriented Perl (oldy but goody)
    • Higher-Order Perl (this one will make you think)
      I definitely agree that the Camel book (Programming Perl) might actually be the way to go, especially if you have a good previous programming experience in another language. The two other books are really really good, but I do not think that they are really an answer to the OP question. Perhaps for a bit later. BTW, Higher Order Perl is available on line (just as Modern Perl, so that it is possible to get a gist of it before buying them (this at least what I did, I read both of them, and then bought them in paper edition, I considered they were definitely worth my money).

      Je suis Charlie.
Re: Re learning Perl
by Discipulus (Canon) on Mar 03, 2015 at 08:50 UTC
    well the learning path are almost non finite numbers..
    Laurent_R++ for your very good answer. But i feel the need to add something:
    I had some problem with Intermediate Perl: is a bit confuse. Dont know if is only my perception. I suggest you to have it anyway (and after this also Mastering Perl): review the index periodically and look if something catch your attention because near a problem you are facing at the moment. For example when is the time for you to make a module you must jump through many different not contigual chapters.

    Laurent_R yet explained the nature of Modern Perl: the key word is in the title, and is an adjective: the first goal of that good book is to give a fresh look at language, because the state of the art of Perl has moved a lot and the book bring a light where shadows were. An example? the context explaination is something i never read in such a clear way.

    As last suggestion, as always, i recommend an old and somehow outdated book: The Perl Cookbook. I suggest to buy it and read it sparsely as side reading. You can profit of many real life examples in many different fields: is like a panorama view.

    A few related nodes:
    how can I learn well
    Advice from elders for a newbie
    Newbie to perl
    Want to learn PERL
    using perl as a new user
    Help for a sporadical scripter.

    HtH
    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: Re learning Perl
by Anonymous Monk on Mar 03, 2015 at 06:20 UTC

    Respected Monks

    Thank you. I've been here so many times, and never ever been turned away with rudeness. I really wish more folks like you were out there at this forum I know of. Unfortunately, it's a forum for a certain version of Linux. Their sullen attitude is direct opposite of what you revered monks exhibit.

    Anyways, as always, thanks monks for your kindness and guidance. I think I'll give Modern Perl a try. Thought it was out of my league, but heck, I'm used to failures more than success :)

Re: Re learning Perl
by project129 (Beadle) on Mar 03, 2015 at 10:09 UTC

    Hi there!

    If you please i recommend concentrate on core details reading

    Camel book (Programming perl) http://shop.oreilly.com/product/9780596004927.do

    and learn (real modern perl :)) about right coding style from

    Perl best practice http://shop.oreilly.com/product/9780596001735.do

    good luck!

    and be free form lang force with you :)

Re: Re learning Perl
by Anonymous Monk on Mar 03, 2015 at 13:22 UTC

    Revered Monks,

    Thanks for your suggestions. I shall certainly try those out.General opinion here seems to favour the Modern Perl very much. I'm already trying that out.

Re: Re learning Perl
by Ea (Chaplain) on Mar 06, 2015 at 11:18 UTC
    18 years and still learning new things.

    Last year, I picked up a second hand copy of Perl Best Practices and thoroughly enjoyed going through it snippet by snippet as an hourly break. There are tons of specialized books on topics like testing, XML, LWP, Web Services, etc. which will teach you Perl as a side effect. You might also consider checking out the Perl Maven site for bite-sized lessons.

    Sometimes I can think of 6 impossible LDAP attributes before breakfast.