RE: removing elements from an array

2003-03-05 Thread Bakken, Luke
> > > 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

RE: removing elements from an array

2003-03-05 Thread Bakken, Luke
> > 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',

Re: removing elements from an array

2003-03-05 Thread Deb
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

RE: removing elements from an array

2003-03-05 Thread Bakken, Luke
> 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

RE: removing elements from an array

2003-03-05 Thread Timothy Johnson
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

RE: removing elements from an array

2003-03-05 Thread Mark Anderson
> 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

removing elements from an array

2003-03-05 Thread David Gilden
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 $_