I got involved in a new project where Perl is a must. I'm coming from a good Ruby foundation and want a quick introduction or mapping between Perl and Ruby as I heard that Perl and Ruby are very close in syntax (know nothing about features).
I second Nathan's book recs, though I would also mention Beginning Perl. Two bonus features are (1) it's available freely (and legally) online in its first edition (note: this site is timing out right now, and I'm unsure if that's temporary or not) and (2) it covers about as much as Learning Perl and Intermediate Perl combined. A con is that it's at times more elementary that you might want. (Learning Perl goes faster and assumes a bit more - which can be a good thing.)
You might also check out this: To Ruby From Perl from Ruby's website. Just think of it in reverse.
In terms of versions, 5.10.1 is stable, but you will come across a range. Mostly you will find 5.8.x and up, I suspect. (Just as with Ruby 1.9.1 is stable but you will find plenty of places still using 1.8.6 or up.)
Since I'm somewhat going in the opposite direction (I know Perl reasonably well, and I'm using Ruby more and more often), I can mention things that stick out to me:
.to_f
or making one item a float).while
block.)0
(string, integer and float), undef
and the empty string evaluate as false
in boolean tests.true
and false
.$foo
is a scalar; @foo
is an array; %foo
is a hash. (Arrays in particular will bug you: they aren't instance variables.)my
keyword.(Note that I didn't mention the 1000 pound gorilla in the room. OO is part of what Perl is and can do, but it's not at the center of Perl, as it is in Ruby.)
In The Perl Survey 2007***, the majority of Perl coders used Perl 5.8, with 87% using 5.8.x at least some of the time, and 5.8.8 being the most common single version. A minority used 5.6.x for at least some projects, and a smaller (but occasionally quite vocal) minority uses 5.005. Since that point Perl 5.10 has been released and it's not clear yet what the adoption rate is; likely many businesses are being conservative and running 5.8.8 or 5.8.9, but many of what you might call "prominent hackers" are using 5.10.1 and even sometimes requiring its features.
perldoc perl
, or you can read online at perldoc.perl.org. These are nearly as good a reference as Programming Perl because in fact a decent portion of that book is drawn from the Perldocs. I would recommend at least a thorough skim of perlsyn, perlop, perlrun, perlvar, perlre, perlobj, perlmod, perluniintro, perlreftut, and perldsc. Reading straight through perlfunc once isn't a bad idea either.***: I would love to provide a link to The Perl Survey 2007 but unfortunately the perlsurvey.org domain was allowed to lapse. A copy of the results PDF may be found at github, and the mostly-raw data is on CPAN as Data::PerlSurvey2007
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With