petdance has asked for the wisdom of the Perl Monks concerning the following question:
Should I use grep? splice? I'd also like to return a 1/0 to indicate the number of fields deleted.
sub delete_field($) { my $self = shift; my $deleter = shift; my @scratch; for ( @{$self->{_fields}} ) { push( @scratch, $_ ) unless ( $deleter == $_ ); } @{$self->{_fields}} = @scratch; }
xoxo,
Andy
--
<megaphone>
Throw down the gun and tiara and come out of the float!
</megaphone>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What's the best metaphor for deleting something from a list?
by John M. Dlugosz (Monsignor) on Aug 10, 2001 at 02:28 UTC | |
|
(dkubb) Re: (2) What's the best metaphor for deleting something from a list?
by dkubb (Deacon) on Aug 10, 2001 at 06:24 UTC | |
|
Re: Counting Deletions From List
by tadman (Prior) on Aug 10, 2001 at 05:01 UTC |