> I would like to remove elements from an array that are eq to 
> string '0'
> The following does not work, can someone shed some light on 
> the proper 
> way to do this.
> Thanks!
> Dave G.
> 
> #!/usr/bin/perl -w
> 
> @bag_quantity = ( '0', 1, '0', '0', '0', '0', '0', '0', '0' ); 
> for (@bag_quantity){
> shift if $_ eq '0';
> }
> print "@bag_quantity\n";

I'm sure there are several ways to do this, and off the top of my head I
don't know which is fastest.

1:

@bag_quantity = grep { $_ ne '0' } @bag_quantity;


2:

my @new_bq;
for (@bq)
{
        push @new_bq, $_ if $_ ne '0';
}

Luke

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to