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 can think of two ways to do it:

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


@tmp = ( map( ($_, '|'), @tmp[ 0 .. $#tmp - 1 ] ), $tmp[ -1 ] );



John

-- 
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