grep in list context (eg, used in a for) will create a new list by selecting elements in its input that match a condition. IE:
foreach (grep { $_ != 0 } @SlectedColumns[1..$NrCoumns]) { # Only non zero elements here }
Edit: and if your input is only numbers, and the content of the loop is just one EXPR, you can even write: print "I'm priting $_!\n" for grep $_, @SlectedColumns[1..$NrCoumns];
In reply to Re: loop array excluding some elements
by Eily
in thread loop array excluding some elements
by IB2017
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |