[ABE.pm] perl 5.10 rules! - say what?
Ricardo SIGNES
rjbs-perl-abe at lists.manxome.org
Thu May 31 08:23:27 PDT 2007
Here's another little one: say
say is stolen from Perl 6. It's just like print, but it prints a newline when
you're done. Seriously, that's it!
print "Nice to meet you, ", $ENV{USER}, ".\n";
say "Nice to meet you, ", $ENV{USER}, ".";
Those lines do the same thing.
What's the big deal? Well, you save four keystrokes, for one, multiplied by
every time you would've used print.
Then there's this:
print @lines, "\n";
say @lines;
There you saved eight keystrokes!
Is this a really small win? I don't know, I think it's a tiny improvement that
you'll really grow to love.
There's one thing to keep in mind: because "say" wasn't a keyword before 5.10,
you'll want to let perl know that you want it to be one now. There are a few
ways to do that:
use feature 'say'; # turn on the "say" feature in this block or file
use feature ':5.10'; # turn on all 5.10 features in this block or file
perl -E 'say "Hello, world!"' # like perl -e, but with all features
--
rjbs
More information about the ABE-pm
mailing list