![]() |
|
Just another Perl shrine | |
PerlMonks |
Why doesn't "my($foo) = <FILE>;" work right?by faq_monk (Initiate) |
on Oct 08, 1999 at 00:27 UTC ( [id://697]=perlfaq nodetype: print w/replies, xml ) | Need Help?? |
Current Perl documentation can be found at perldoc.perl.org. Here is our local, out-dated (pre-5.6) version:
my() and local() give list context to the right hand side of To enforce scalar context in this particular case, however, you need merely omit the parentheses:
local($foo) = <FILE>; # WRONG local($foo) = scalar(<FILE>); # ok local $foo = <FILE>; # right You should probably be using lexical variables anyway, although the issue is the same here:
my($foo) = <FILE>; # WRONG my $foo = <FILE>; # right
|
|