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 | |
by pritesh (Scribe) on Mar 02, 2015 at 21:42 UTC | |
by kroach (Pilgrim) on Mar 02, 2015 at 22:21 UTC | |
Re: Re learning Perl
by Laurent_R (Canon) on Mar 02, 2015 at 23:36 UTC | |
Re: Re learning Perl
by AppleFritter (Vicar) on Mar 02, 2015 at 22:17 UTC | |
Re: Re learning Perl
by dmitri (Priest) on Mar 03, 2015 at 04:50 UTC | |
by Laurent_R (Canon) on Mar 03, 2015 at 07:44 UTC | |
Re: Re learning Perl
by Discipulus (Canon) on Mar 03, 2015 at 08:50 UTC | |
Re: Re learning Perl
by Anonymous Monk on Mar 03, 2015 at 06:20 UTC | |
Re: Re learning Perl
by project129 (Beadle) on Mar 03, 2015 at 10:09 UTC | |
Re: Re learning Perl
by Anonymous Monk on Mar 03, 2015 at 13:22 UTC | |
Re: Re learning Perl
by Ea (Chaplain) on Mar 06, 2015 at 11:18 UTC |