[Chicago-talk] Delete element from array

Mike Demir mdemir3000 at gmail.com
Fri Jul 11 10:51:31 PDT 2008


So here is my quandry. I have a list of stock symbols stored in array
(@sym), and am looking to test each symbol against a series of conditions
(foo1, foo2....). When the condition is met, I would like to remove that
symbol and return to the top of the loop to start working on the next
symbol. If the symbol fails all the test conditions, it should remain in the
array. I'm having no trouble getting the test conditions to work, or the
looping to work. However I can't seem to remove the symbol from the array.
It's a conceptual thing at this point, so a solution is nice but not
required. Need to understand.

What I'm seeing is that only the $symbol[0] gets deleted.

So here's what I had attempted...

foreach $symbol (@symbol) {
            if (foo1) {
            delete $symbol[];
            if (foo2) {
            delete $symbol[];

Many thanks for your time.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20080711/0919ac6f/attachment.html>

More information about the Chicago-talk mailing list