> > > 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.
Here's an interesting benchmark comparing the splice, new list, and grep
(grep
> > 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',
Why not use a foreach, test the element, then undef it when found?
Or, use foreach, test the element, if != '0', then push it onto
another array?
David Gilden <[EMAIL PROTECTED]> had this to say,
> Hi,
> I would like to remove elements from an array that are eq to string '0'
> The following d
> 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_qu
element as
undef and doesn't really remove it. I think you want something closer to
this:
@bag_quantity = grep( whatever... );
check out perldoc -f grep
-Original Message-
From: David Gilden [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 05, 2003 9:39 AM
To: [EMAIL PROTECTED]
Subjec
> Hi,
> 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.
look at the grep function:
perldoc -f grep
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional
Hi,
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 $_