Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: does split(".") work?

by jwkrahn (Monsignor)
on Nov 16, 2009 at 00:23 UTC ( #807339=note: print w/ replies, xml ) Need Help??

in reply to Re: does split(".") work?
in thread does split(".") work?

Dot "." is the "match-all" character in a regex so your split won't return anything.

Actually split returns a lot of things, it's just that the way list assignment works there is nothing left to put in the array.    If you make a slight change you can see everything that split returns:

$ perl -le'my $ip=""; my @values = split(".", $ip, -1); pr +int $ip,"\t\t",$#values,"\n";' 12
Comment on Re^2: does split(".") work?
Download Code
Replies are listed 'Best First'.
Re^3: does split(".") work?
by ysth (Canon) on Nov 16, 2009 at 05:45 UTC
    Not sure what you mean about list assignment; the difference is that a third parameter of -1 makes split keep trailing empty strings where by default it discards them. In your example, split returns 13 empty strings (one from before the first character of $ip, one for each position between characters, and one from after the last character.)
    A math joke: r = | |csc(θ)|+|sec(θ)|-||csc(θ)|-|sec(θ)|| |
    Online Fortune Cookie Search
    Office Space merchandise

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2016-05-26 11:52 GMT
Find Nodes?
    Voting Booth?