<span class="Apple-style-span" style="border-collapse: collapse; ">This is a perfect place to use the grep function. You want an array of good symbols, so grep can select all elements that are not bad.<div><br></div><div><div>
my @sym = ...;</div><div><br></div><div>sub symbol_is_bad {</div><div>&nbsp;&nbsp; &nbsp;my $symbol = shift;</div><div><br></div><div>&nbsp;&nbsp; &nbsp;if (foo1) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return 1;</div><div>&nbsp;&nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;if (foo2) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return 1;</div>
<div>&nbsp;&nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;...</div><div><br></div><div>&nbsp;&nbsp; &nbsp;return;</div><div>}</div><div><br></div><div>my @good_sym = grep { not symbol_is_bad($_) } @sym;</div><div><br></div></div><div>--</div></span>Leland Johnson
<br><br><div class="gmail_quote">On Fri, Jul 11, 2008 at 12:51 PM, Mike Demir &lt;<a href="mailto:mdemir3000@gmail.com">mdemir3000@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi:<br><br>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&nbsp; (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&#39;m having no trouble
getting the test
conditions to work, or the looping to work. However I can&#39;t seem to
remove the symbol from the array. It&#39;s a conceptual thing at this
point, so a solution is nice but not required. Need to understand.<br><br>What I&#39;m seeing is that only the $symbol[0] gets deleted.<br>
<br>So here&#39;s what I had attempted...<br><br>foreach $symbol (@symbol) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (foo1) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delete $symbol[];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; next;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (foo2) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delete $symbol[];<br>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; next;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .<br>}<br><br>Many thanks for your time.<br><font color="#888888"><font color="#888888"><br>Mike</font>
</font><br>_______________________________________________<br>
Chicago-talk mailing list<br>
<a href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br></blockquote></div><br>