Subject: cool tricks for inserting element into array?


I'd like to turn array @tmp from:

   (1,2,3)

to

   (1,"|",2,"|",3)

I'm using:

  @tmp = split(' ', join(" | ", @tmp));

... but it seems like a waste to create a string and then split it back up
again.

As a sidenote, are questions like this appropriate for the list?  I really
don't *need* help with this, I was just hoping to expand my personal toolbox
with a better way to do something.  Every time John, Wiggins, Luke, Bob,
Jeff, etc. respond to my emails I know I'm going to learn something.

- Bryan


Not sure if this helps but ...

perl -e '@tmp=(1..4); @tmp = map {$_, "|"} @tmp; print "@tmp";'

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


Reply via email to