note
tobyink
<p>If you want to filter elements out of an array, use <c>grep</c> (see [mod://perlfunc]). For example, to keep only strings which have a length of at least 1 character, you could use:</p>
<code>
my @strings = split "\t", $line;
my @keep = grep { length($_) >= 0 } @strings;
</code>
<p>This can be made more concise:</p>
<code>
my @keep = grep { length($_) } split "\t", $line;
</code>
<p>Or even:</p>
<code>
my @keep = grep length, split "\t", $line;
</code>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-757127">
<small><small>
<tt>perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
</tt></small></small>
</div></div>
1003565
1003583