Consider
my @array = ( 'x' =~ /y/, 'x' eq 'y', 1 == 2 );
and
my %hash = ( 'a', 'x' =~ /y/, 'b', 'x' eq 'y', 'c', 1 == 2 );
Using Data::Dumper, we see that =~ behaves differently than eq and ==
\@array = [
'',
''
];
\%hash = {
'a' => 'b',
'' => undef
};
Specifically it appears that the snippets of code above are being interpreted as
my @array = ( 'x' eq 'y', 1 == 2 );
and
my %hash = ( 'a', 'b', 'x' eq 'y', 'c', 1 == 2 );
Can someone provide an explanation for this arguably unexpected behavior?