$ ./perl -Ilib -e '${function_with_side_effects,42}'
$ ./perl -Ilib -e '${Function_with_side_effects,42}'
syntax error at -e line 1, near "${"
Execution of -e aborted due to compilation errors.
Why is the second one a syntax error?
Because the lexer is trying to disambiguate between a block and a hash
when it sees ‘{’ after ‘$’. But an anonymous hash constructor cannot
come after a funny character, so any time it chooses the hash inter-
pretation over the blocky one, a syntax error ensues.
#!./perl
-print "1..92\n";
+print "1..93\n";
$x = 'x';
# [perl #80368]
print "not " unless eval '"a\U="' eq "a=";
print "ok $test - [perl #80368] qq <a\\U=>\n"; $test++;
+
+sub Function_with_side_effects { $_ = "sidekick function called" }
+print "not " unless
+ (eval '${Function_with_side_effects,\$_}' || $@)
+ eq "sidekick function called";
+print "ok $test - \${...} where {...} looks like hash\n"; $test++;
}
OPERATOR(HASHBRACK);
}
+ if (PL_expect == XREF && PL_oldoldbufptr != PL_last_lop) {
+ /* ${...} or @{...} etc., but not print {...} */
+ PL_expect = XTERM;
+ break;
+ }
/* This hack serves to disambiguate a pair of curlies
* as being a block or an anon hash. Normally, expectation
* determines that, but in cases where we're not in a