Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: ignoring empty returns from split

by sachmet (Scribe)
on Apr 24, 2001 at 04:11 UTC ( #74917=note: print w/replies, xml ) Need Help??


in reply to Re: ignoring empty returns from split
in thread ignoring empty returns from split

That fails on the case where $line starts with a =:
$line = "==one==two==three"; ($one,$two,$three,$four)=split (/=+/,$line); print "$one\n$two\n$three\n$four";
gives me an undef, 'one', and 'two'.

As a side note, '$line' != '$a' :-)

Afterthought: This would work:
$line = "==one==two==three=four"; ($one,$two,$three,$four)=split (/=+/,($line=~/^=*(.*?)$/,$1)[1]); print "$one\n$two\n$three\n$four";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2021-04-16 18:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?