develooper Front page | perl.golf | Postings from July 2002

Re: Golf this.

Thread Previous
From:
=?iso-8859-1?Q?Beno=EEt_Chauvet?=
Date:
July 16, 2002 00:25
Subject:
Re: Golf this.
Message ID:
140601c22c99$b2e0ca90$380aa8c0@brightrivers.vpn

----- Original Message -----

> En op 16 juli 2002 sprak |3en:
> > Hu... I may make a mistake, but...
> >
> > Isn't this one...
> > -p $h{$_}++}for(sort%h){
> >
> > ...shorter ?
>
> Yes |3en, this is your third mistake.
> Your first was challenging `/ in tpr04, and your
> second was challenging him yet again in tpr04b.
>
> Because we are using %h and not keys%h you must
> set it to "" and not a number. Rick's
>   -p $h{$_}=1}for(sort%h){
> suffers from the same bug.

You're right ! I just didn't noticed that 'keys' was not even used (I just
woke up too early this morning, I'm not sure my eyes are opened enough for
working. At least, not enough for Golfing, obviously...)

>
> You can fix like this:
>   #!perl -p
>   $h{$_}++}for(sort keys%h){

Of course... Thanks for the lesson...

--
|3enoƮt, humiliated again...


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About