[ABE.pm] Perl 5.10 rocks
Ted Fiedler
fiedlert at gmail.com
Wed Jun 6 13:31:10 PDT 2007
just to reiterate on damn cool features ...
#!/opt/perlbleed/bin/perl
use strict;
use warnings;
use feature ":5.10";
my $isuniq = \&isuniq;
while(<>)
{
given ($_)
{
when ( /^(\S.*)$/ ) { say "you said $1 ",$isuniq->($1)," times" }
default { say "you said nothing ",$isuniq->(qq{nothing})," times" }
}
}
sub isuniq
{
state %count;
return ++$count{$_}{'count'};
}
--
The optimist thinks that this is the best of all possible worlds,
and the pessimist knows it.
-- J. Robert Oppenheimer, "Bulletin of Atomic Scientists"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070606/27e1752f/attachment.html
More information about the ABE-pm
mailing list