John W. Krahn wrote:
John W. Krahn wrote:
Robert Citek wrote:
On Jan 8, 2008 9:40 AM, Robert Citek <[EMAIL PROTECTED]> wrote:
On Jan 8, 2008 9:24 AM, Robert Citek <[EMAIL PROTECTED]> wrote:
What I really want to know is if there's a way to eliminate the
temporary variable.  If not, that's fine.  I was just wondering if
there's something I'm overlooking.  Come to think of it, maybe I could
use map.
Here's an example closer to the real problem:

$ ls | perl -e '@F=(<>) ; chomp @F ; print "('\''" .
join("'\'',\n'\''",@F) . "'\'') \n" ; '

Yup.  map works:

$ ls | perl -e 'print "('\''" . join("'\'','\''", map { chomp; $_ }
(<>) ) . "'\'') \n" ; '


$ ls | perl -le 'print "(", join ",", map( { chomp; "\047$_\047" } <> ), ")"'

You don't really need ls either:

$ perl -le 'print "(", join ",", map( { chomp; "\047$_\047" } <*> ), ")"'

Or chomp:

$ perl -le 'print "(", join ",", map( "\047$_\047", <*> ), ")"'


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to