The => is just a fat comma and the declaration resets the var to undef.
So our $foo => 1; -> undef, 1;
I suppose that at runtime the scalar comma operator will only try to "return" the last statement to void (I know this sounds weird°)
And 0 and 1 are allowed in void (think modules needing a true return value).
That's why the error is only caught for other values.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
°) from Programming Perl
Binary "," is the comma operator. In scalar context it evaluates its left argument in void context, throws that value away, then evaluates its right argument in scalar context and returns that value.
In reply to Re^2: Detecting 'our $foo => 1' mistake? (scalar comma evaluating to 1)
by LanX
in thread Detecting 'our $foo => 1' mistake?
by perlancar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |