Re: Modifying Array inside While statement
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel)
- Date: 29 Dec 2005 21:37:34 GMT
John W. Krahn <krahnj@xxxxxxxxx> wrote in comp.lang.perl.misc:
> ced@xxxxxxxxxxxxxxxxxxxxx wrote:
> > for ( reverse 0..$#my_array) {
> > unshift @new_array, splice @my_array, $_, 1 if $my_array[$_] =~
> > /new/;
> > }
>
> Or:
>
> push @{ /new/i ? \@new_array : \@my_array }, $_ for splice @my_array;
Ah... splice with just an array clears the array and returns a copy. I never
noticed.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.
- Follow-Ups:
- Re: Modifying Array inside While statement
- From: robic0
- Re: Modifying Array inside While statement
- References:
- Modifying Array inside While statement
- From: Andy
- Re: Modifying Array inside While statement
- From: Anno Siegel
- Re: Modifying Array inside While statement
- From: ced@xxxxxxxxxxxxxxxxxxxxx
- Re: Modifying Array inside While statement
- From: John W. Krahn
- Modifying Array inside While statement
- Prev by Date: Re: Ordering string of commands in a file
- Next by Date: Re: My Regexp XML Parser -> Structured Perl Data, Cut & Paste Version, No Module's (Vol I)
- Previous by thread: Re: Modifying Array inside While statement
- Next by thread: Re: Modifying Array inside While statement
- Index(es):