Bryan R Harris wrote:
> 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.

I'll bet that's pretty efficient. The problem would come if any of the
original elements contained an embedded space.

Here's a way, but I doubt it's very efficient:

   splice @tmp, $_, 0, '|' for reverse 1 .. @tmp-1;

Another way:

   @tmp = map +($_, '|'), @tmp; pop @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