http://www.perlmonks.org?node_id=1003586


in reply to Re^6: Split output by tabs (not clear)
in thread Split output by tabs

If you want to filter elements out of an array, use grep (see perlfunc). For example, to keep only strings which have a length of at least 1 character, you could use:

my @strings = split "\t", $line; my @keep = grep { length($_) >= 0 } @strings;

This can be made more concise:

my @keep = grep { length($_) } split "\t", $line;

Or even:

my @keep = grep length, split "\t", $line;
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'