"R. Joseph Newton" wrote:

> David Inglis wrote:
>
> > Is there a command to drop an element from an array, or what is the best
> > way to do this.
> >
> > Any help appreciated.
> >
> > --
> > Regards
> >
> > David Inglis
>
> If at all possible, design around the need.

Sorry if the above was too curt and cryptic.  I do feel, though, that in most
cases the need to delete elements from within an array would raise questions
about whether the array was the appropriate structure for the data.  You
certainly have to be aware of the difference between an index-shifting removal
of an element,which will throw offany index-based calculations, and the deletion
of values from elements left in place, which bringsto mind the picture of an
average American strip mall in the Age of Dubya, rows of dismal commercial cells
interspersed with empty storefronts.

In cases where you need to filter a list, Iwould suggest That you structure the
filter processing so that the filtered list is the natural output of the
processing:

my @filtered;
while (my $test_element = shift @$unfiltered) {
   push @filtered, $test_element  if passes_test($test_element);
}
@$unfiltered = @filtered

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to