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.
|