Can anyone explain why the @options array in the following code snippet doesn't gobble up the empty field at the end?
my $str = "foo:bar:";
my( $a, @options ) = split /:/, $str;
my( $b, $c, $d ) = split /:/, $str;
use Data::Dumper;
print Dumper( [ $a, \@options ] );
print Dumper( [ $b, $c, $d ] );
$VAR1 = [
'foo',
[
'bar'
]
];
$VAR1 = [
'foo',
'bar',
''
];
This seems to have to do with split(), as
my( $a, @options ) = ( "foo", "bar", "" );
my( $b, $c, $d ) = ( "foo", "bar", "" );
use Data::Dumper;
print Dumper( [ $a, \@options ] );
print Dumper( [ $b, $c, $d ] );
gobbles up everything correctly:
$VAR1 = [
'foo',
[
'bar',
''
]
];
$VAR1 = [
'foo',
'bar',
''
];