Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^7: Split output by tabs (not clear)

by tobyink (Abbot)
on Nov 13, 2012 at 10:19 UTC ( #1003586=note: print w/ replies, xml ) Need Help??

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'

Comment on Re^7: Split output by tabs (not clear)
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1003586]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2015-11-30 10:26 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (769 votes), past polls