Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Matching dot using regexp

by huck (Prior)
on Oct 09, 2017 at 18:46 UTC ( [id://1201035]=note: print w/replies, xml ) Need Help??


in reply to Matching dot using regexp

I had to think for a bit as to why it was undefined rather than ''

split notes "If LIMIT is omitted (or, equivalently, zero), then it is usually treated as if it were instead negative but with the exception that trailing empty fields are stripped (empty leading fields are always preserved);"

use warnings; use strict; my $t0="01.00.01.004"; my @o0 = split /./, $t0; my @om1 = split /./, $t0,-1; use Data::Dumper; print " 0\n".Dumper(\@o0); print "-1\n".Dumper(\@om1);
Result
0 $VAR1 = []; -1 $VAR1 = [ '', '', '', '', '', '', '', '', '', '', '', '', '' ];

Without the -1 any char is a delimiter, and there are no "fields" between delimiters, so all are stripped. With the -1, while all are delimiters and there are no "fields" between delimiters, each delimiter returns an empty field.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-26 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found