[Chicago-talk] Why won't this work?
Andy Lester
andy at petdance.com
Wed Aug 1 07:01:32 PDT 2007
On Aug 1, 2007, at 8:56 AM, Richard Reina wrote:
> foreach $def (@arr) {
> if ($def eq "b") {
> my $trash = shift # get rid of (trash) b
> }
> }
>
> print "@arr\n";
>
> "b" does not get eliminated?
Because you're shifting from @ARGV, not @arr.
The better way to do it is to replace the entire for loop with:
@arr = grep { $_ ne 'b' } @arr;
xoxo,
Andy
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
More information about the Chicago-talk
mailing list