SPUG: itm 60 in effective perl programming

Yitzchak Scott-Thoennes sthoenna at efn.org
Thu Feb 24 05:40:28 PST 2005


On Thu, Feb 24, 2005 at 04:49:34AM -0800, John W. Krahn wrote:
> John W. Krahn wrote:
> >Yitzchak Scott-Thoennes wrote:
> >>perl -pl40w010e0 file
> >
> >Octal 010 is the backspace character, it should be 012 for newline:
> >
> >perl -012l40pe0

Urrgh.  I hate octal.  Thanks.

> >perl -lpe'$,.=$_.$"}{$\=$,'
> >
> >or
> >
> >perl -pe'/.*/;$\.=$&.$"}{'
> 
> Or to do what the original did without using a regular expression:
> 
> perl -lpe'$;.=$_.(--$|?$":$/)}{$\=$;'
> 
> or even
> 
> perl -pe'/.*/;$\.=$&.(--$|?$":$/)}{'

That last is my favorite.  I've always been partial to code without any
unsightly alphanumerics.


More information about the spug-list mailing list