Я не понимаю знак сахара +
в этом примере, взятый где-то во время просмотра:
sub bar { +{$_[1] => $_[2]} }
Я написал это, и здесь я не вижу различий:
use Data::Dumper;
# Not any differences here
my $foo = {value => 55};
my $bar = +{value => 55};
print Dumper $foo;
print Dumper $bar;
# Oh ! Here there is something...
sub foo { {$_[1] => $_[2]} };
sub bar { +{$_[1] => $_[2]} };
print Dumper foo('value', 55);
print Dumper bar('value', 55);
foo
возвращает
$VAR1 = 55;
$VAR2 = undef;
bar
возвращает
$VAR1 = {
'55' => undef
};