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

Re: Golf this.

Thread Previous | Thread Next
From:
Paul Johnson
Date:
July 16, 2002 02:38
Subject:
Re: Golf this.
Message ID:
20020716093645.GH1217@pjcj.net
On Tue, Jul 16, 2002 at 11:22:46AM +0200, Francesc X.Noria wrote:
> On Tue, 16 Jul 2002 16:07:33 +1000
> Andrew.Savige@ir.com wrote:
> 
> : How about this?
> : 
> : #!perl -p
> : $h{$_}=""}for(sort%h){
> 
> I cannot see how that works. Why is $_ not printed in each loop? How
> that strange position of braces (...}...{) work? When and how is the for
> looping? I would be very grateful if you could explain it a bit or point
> to some earlier thread in case that was treated earlier in this list.

$ perl -MO=Deparse -pe '$h{$_}=""}for(sort%h){'
LINE: while (defined($_ = <ARGV>)) {
    $h{$_} = '';
}
foreach $_ (sort %h) {
    ();
}
continue {
    print $_;
}
-e syntax OK

-- 
Paul Johnson - paul@pjcj.net
http://www.pjcj.net

Thread Previous | Thread Next


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