Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Parentheses missing around "my" list

by a (Friar)
on Jul 27, 2011 at 19:56 UTC ( [id://917118]=note: print w/replies, xml ) Need Help??


in reply to Parentheses missing around "my" list

Yeah, my guess is that open is looking at the the 'my' stuff in list context, that is, open takes 1, 2, 3 or more arguments and you can put an array var in the first position - so my is warning you that you've got an un-paren-ed list of vars because open's trying to get it to handle the rest of the list. "my" is a uni-valued function (so you need parens/list for multiple values). If you use the 3 element form (your example has the var names backwards or, misleading, anway) though:
open my $filehandle, ">", $file
or add the 'or die ... ' test
open my $filehandle, $file or die "can't open $file: $!";
(both recommended best practices for "open") you don't get the complaint. Yeah, not really the clear-cut answer you were looking for though ... hmm, may just be a parser corner case:
$ perl -e 'use warnings; use strict; my $filename = "/tmp/hey"; open m +y $file, $filename' $ perl -e 'use warnings; use strict; my $filename = "/tmp/hey"; open m +y $file, $filename;' Parentheses missing around "my" list at -e line 1.
only diff is the final semicolon before the close quote

a

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://917118]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-20 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found