Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: split line

by ysth (Canon)
on Jul 29, 2008 at 03:18 UTC ( [id://700722]=note: print w/replies, xml ) Need Help??


in reply to Re: split line
in thread split line

When you're splitting on any whitespace, you want to use \s+ instead of " ".
except when you want to use " ", which does just what you want, including saving the hassle of the empty first element:
$ perl #!/usr/bin/perl -w use strict; my $line = " 0\t10\n 9 4 \r 1 0 0 \t0 2 2 1 1 0"; my @config = split " ", $line; for (@config) { print $_, "\n"; } __END__ 0 10 9 4 1 0 0 0 2 2 1 1 0

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-19 15:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found