in reply to Re: Deleteing array elements
in thread Deleteing array elements
@arr = grep { $_ !~ /c/ } @arr;
That works, of course, with the sample data that we've been given, but in the general case it will remove any element that contains the letter 'c'.
Regular expressions aren't always the answer. Sometimes a simpler approach is right.
@arr = grep { $_ ne 'c' } @arr;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Deleteing array elements
by si_lence (Deacon) on Jul 23, 2009 at 08:55 UTC |
In Section
Seekers of Perl Wisdom