D
Dave Slayton
I have a hash full of filehandles and a scalar variable containing a line of
text, and try to do this:
print $fh_hash{$key} $line;
which is rejected by the compiler, which says "Scalar found where operator
expected" near "} $line". It wants an operator before $line? I tried
placing parentheses around $line, but that is likewise rejected on the basis
of its not being a code reference, so it presumably thinks I'm using the
parentheses to call a subroutine. I'm clearly not understanding the parsing
that's happening there. Finally, if I surround the file handle with curly
braces like this:
print {$fh_hash{$key}} $line;
then it works as desired.
Would someone please explain what's going on there?
Thanks!
text, and try to do this:
print $fh_hash{$key} $line;
which is rejected by the compiler, which says "Scalar found where operator
expected" near "} $line". It wants an operator before $line? I tried
placing parentheses around $line, but that is likewise rejected on the basis
of its not being a code reference, so it presumably thinks I'm using the
parentheses to call a subroutine. I'm clearly not understanding the parsing
that's happening there. Finally, if I surround the file handle with curly
braces like this:
print {$fh_hash{$key}} $line;
then it works as desired.
Would someone please explain what's going on there?
Thanks!