Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: sort syntax

by thelenm (Vicar)
on Oct 16, 2003 at 19:56 UTC ( [id://299868]=note: print w/replies, xml ) Need Help??


in reply to Re: sort syntax
in thread sort syntax

It compiles okay for me (don't know if it was changed since you posted). The }{ looks funny in the middle of the code, but it's just taking advantage of the fact that the -n flag assumes the following loop around the program as documented in perlrun:

LINE: while (<>) { ... # your program goes here }

Putting }{ in the middle of the "your program goes here" section is a Perl golf trick that I believe was invented by Eugene Van der Pijll. It makes the code before it part of the while loop, and the code afterward gets executed outside the loop. Using the -n flag causes perl to literally put the while loop around it, as you can see if you do this:

perl -MO=Deparse -lne '$x{1,sort/./g}.=$_}{/./&& print for %x'

-- Mike

--
XML::Simpler does not require XML::Parser or a SAX parser. It does require File::Slurp.
-- grantm, perldoc XML::Simpler

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://299868]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-19 11:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found