in reply to Re: Perl as a Holy Weapon?
in thread Perl as a Holy Weapon?
to justfor my $letter ( split // => $phrase ) { $sum += $numeral{$letter} || 0; }
Remember list context m//g. Once you get your head around it, you can do many things for which split seemed awkward.use List::Util qw(sum); # in the CPAN $sum = sum map $numeral{$_}, $phrase =~ /([IVXCLMD])/g;
-- Randal L. Schwartz, Perl hacker
|
|---|