in reply to FileHandle in a Hashref
Why?
In print $handle @args the $handle is syntactically distinct from an ordinary argument in there is no space between it and the following arguments.
This is forbidden in "normal" perl code, we call it "two terms in a row" (short TTIAR)
So if Perl allowed arbitrary expressions as file handles, it wouldn't catch TTIAR errors later, leading to extremely weird behavior. Consider
print $some + $var * 5 3; # ^ # forgot an operator
In this example, everything up to (and including) the 5 would be parsed as a file handle if Perl allowed arbitrarily complex expressions as file handles. No syntax error would be emitted.
So, there needs to be a complexity limit as to what is allowed as a file handle. The choice is "a single variable, bareword or { ... } block".
|
|---|