06 — Perl heritage¶
Ruby's About page ↗ says its author "blended parts of his favorite languages", and names Perl first. For text processing Perl is the one you can see: the command-line switches, the special variables, split, string increment, pack, and the regex syntax. Each lesson here runs the Ruby and the Perl on the same input.
The two agree more often than a Ruby programmer might expect, and where they disagree the difference is small enough to survive a port unnoticed. Other chapters have Perl comparisons of their own: chomp, anchors and /m, \h and <<~.
| Lesson | The one thing |
|---|---|
ruby -n -p -a -F -l -i came from Perl |
six one-liners, twice each, same output |
split has an awk mode |
split(" ") is not a split on a space |
succ counts in letters |
"az".succ is "ba", and where Perl stops |
pack and unpack speak Perl's template language |
the same letters, the same bytes |