You don't want to use shift in the middle of a for or foreach. shift removes the first element of the array, and you're just asking for trouble mucking with the structure of an array as you're cycling through it. delete() won't work either, as it pretty much just marks the 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] Subject: removing elements from an array 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 $_ eq '0'; } print "@bag_quantity\n"; ============================================== Cora Connection: Your West African Music Source Resources, Recordings, Instruments & More! <http://www.coraconnection.com/> ============================================== -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]