Tony Cook
2024-01-19 03:14:48 UTC
$_ does not seem to be evaluated, or at least the result not saved, by the
200 200
Is this a bug?
This isn't specific to $_:200 200
Is this a bug?
$ perl -E 'my $x = 100; @a = ( $x, do { $x = 200 } ); say "@a"'
200 200
$ perl -E 'my @x = 100; @a = ( @x, do { $x[0] = 200 } ); say "@a"'
200 200
# be careful with aggregates though, -DPERL_RC_STACK in blead should fix this:
$ perl -E 'my @x = 100; @a = ( @x, do { @x = 200 } ); say "@a"'
semi-panic: attempt to dup freed string at -e line 1.
200
When building a list with a variable, perl pushes the SV for the
variable on the stack, not a copy, so in these cases the modification
to the variable is reflected in the final list.
Tony