Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: split line

by Your Mother (Archbishop)
on Jul 28, 2008 at 21:44 UTC ( #700674=note: print w/replies, xml ) Need Help??


in reply to Re^2: split line
in thread split line

dwm042's answer below does this but there's a shortcut specifically for this kind of thing. Try this:

my $line = " 0 10 9 4 1 0 0 0 2 2 1 1 0"; my @config = grep /\S/, split / /, $line; # or even my @config = grep /\A\d+\z/, split / /, $line; print join(", ", @config), "\n";

The second will only pass through numbers (well, positive integers and zero) so something like "6a" will be skipped.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2022-10-02 10:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (8 votes). Check out past polls.

    Notices?