develooper Front page | perl.golf | Postings from March 2005

RE: Perl golf article at Perl Monks

From:
Johnson, Roy R SIEP
Date:
March 10, 2005 10:57
Subject:
RE: Perl golf article at Perl Monks
Message ID:
A3B4E948E728054CAC7A6D9C55EAB6A3010E6E50@houic-s-348.americas.shell.com
perl -pi -e '$_=<>.$_;eof||redo' in.file

> -----Original Message-----
> From: Ala Qumsieh [mailto:ala_qumsieh@yahoo.com]
> Sent: Thursday, March 10, 2005 11:49 AM
> To: Jasper
> Cc: golf@perl.org
> Subject: Re: Perl golf article at Perl Monks
> 
> 
> 
> --- Jasper <jaspermccrea@gmail.com> wrote:
> 
> > Nice. Perhaps it'll prompt a new compo soon :)
> 
> Ahhh .. how I long for the good old days.
> Speaking of that, there was a post yesterday on
> comp.lang.perl.misc asking about a one-liner to
> reverse the lines in a file in-place. So the input
> file itself must be modified and no other files must
> be created.
> 
> I came up with this:
> perl -aF"\n" -lp0 -i -e '$_=join$\,reverse@F' in.file
> 
> But then, I remembered Eugene's (in)famous solution to
> reverse sort, but couldn't get it to work:
> 
> perl -pi -e '$x=$_.$x}{$_=$x' in.file
> 
> This prints to screen, not back to the file.
> Any takers?
> 
> --Ala
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> 




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