Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: can split() use a regex?

by davidrw (Prior)
on Jun 17, 2006 at 16:02 UTC ( [id://555989]=note: print w/replies, xml ) Need Help??


in reply to Re: can split() use a regex?
in thread can split() use a regex?

or use (and IMHO better because it clearly designates it as a regex to the reader) the normal //:
my ($one, $two) = split( /\d+\s+/, $line);
BUT.. you need the delimeter as $one .. so need to capture it:
my ($one, $two) = split( /(\d+\s+)/, $line);
BUT .. that will have the space in $one .. so use a look-behind (see perlre) instead .. (and add the LIMIT)
my ($one, $two) = split /(?<=\d+)\s+/, $line, 2;
so to OP -- yes, it's possible w/split & regex ;)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (9)
As of 2024-03-28 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found