in reply to Re: Inserting into an array while stepping through it
in thread Inserting into an array while stepping through it

Well, map() is a good alternate solution (though it wouldn't be doing the modification in place exactly.) But, you didn't show how to use it in the way he wants to...

@list = map { $_ eq 'condition' ? my_sub( $_ ) : $_ } @list;
and yes, that'll work when my_sub() returns a list too.

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re: Re: Re: Inserting into an array while stepping through it
by meredith (Friar) on Jun 13, 2003 at 02:52 UTC
    Thanks for the code -- I just wanted to include an explanation for the code I posted, instead of a one-liner and some code. Anonymous Monk sure posts a lot of questions, and I want to help him learn. ;) Besides, everyone knows that using map scores you extra Perl Points(tm)!!

    mhoward - at - hattmoward.org