Friday Perl Challenge
Luis Motta Campos
luismottacampos at yahoo.co.uk
Fri Apr 20 14:15:54 BST 2007
On Apr 20, 2007, at 2:04 PM, Joel Bernstein wrote:
> On Fri, Apr 20, 2007 at 01:19:57PM +0200, Luis Motta Campos wrote:
>> Do I win extra points for using a /e regexp? :-)
>
> Yes, but you lose them again for using $&...
I choosed them instead of using capturing parentesis, that are
forbidden... :-(
>> perl -nle 's{\S+}{$w{$&}++;}eg}{print"$_,$w{$_}"for sort keys%w'
>
> Your ; inside the s{}{} is superfluous
Yes. That makes it a char shorter:
perl -nle 's{\S+}{$w{$&}++}eg}{print"$_,$w{$_}"for sort keys%w'
--
Luis Motta Campos (a.k.a. Monsieur Champs) is a software engineer,
Perl fanatic evangelist, and amateur {cook, photographer}
More information about the london.pm
mailing list