[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] TPJ One-Liner #39



Quoting Ronald J Kimball (rjk@linguist.dartmouth.edu):
> How could the following one-liner (#39) from the latest Perl journal be
> improved?
> 
> perl -ne 'push@w,/(\b[A-Z]\S*?\b)/g;END{print"@w"}'

I rather like

perl -ne '$,=$";print/(\b[A-Z]\S*?\b)/g,"";'

It puts a space on the end, but the output is otherwise identical. The $,=$"
(which is a smart-alecky way of saying $,=" ") could be put in a BEGIN{}
block for efficiency, but that would make it all big and ugly.

-- 
Adam Rice -- wysiwyg@glympton.airtime.co.uk -- Blackburn, Lancashire, England

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe