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

Re: Re: Perl golf article at Perl Monks

Thread Previous
From:
Vidul Petrov
Date:
March 10, 2005 11:06
Subject:
Re: Re: Perl golf article at Perl Monks
Message ID:
1411999697.1110481560176.JavaMail.nobody@app6.ni.bg
Traditional way:

perl -i -ne 'unshift@_,$_;eof&&print@_' in.file



 >-------- Îðèãèíàëíî ïèñìî --------
 >Îò:  Eirik Berg Hanssen <Eirik-Berg.Hanssen@allverden.no>
 >Îòíîñíî: Re: Perl golf article at Perl Monks
 >Äî: Ala Qumsieh <ala_qumsieh@yahoo.com>
 >Èçïðàòåíî íà: ×åòâúâòúê, 2005, Ìàðò 10 20:40:18 EET
 >----------------------------------
 >
 >Ala Qumsieh <ala_qumsieh@yahoo.com> writes:
 >
 >> 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?
 >
 >  (It prints to screen because the special output file is no longer
 >select()ed.  But you all knew that.)
 >
 >  My take:
 >
 >perl -ni -e 'eof&&print;$\=$_.$\' in.file
 >
 >
 >Eirik
 >-- 
 >GUIs normally make it simple to accomplish simple actions and
 >impossible to accomplish complex actions.
 >        -- Doug Gwyn (in comp.unix.wizards on June 22, 1991)
 >

-----------------------------------------------------------------
http://gbg.bg/search - Èçïðîáâàéòå îùå ñåãà íàé-äîáðàòà áúëãàðñêà òúðñà÷êà!

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