develooper Front page | | Postings from March 2005

Re: Perl golf article at Perl Monks

Eirik Berg Hanssen
March 10, 2005 10:40
Re: Perl golf article at Perl Monks
Message ID:
Ala Qumsieh <> 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

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) Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About