In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (B McKee) writes:
>On Tuesday, January 20, 2004, at 10:34  AM, B McKee wrote:
>
>> Hi All,
>> I'm having trouble understanding what use strict is trying to tell me.
>> If I have run this program
>...snipped
>> open(MESSAGE, "$datafile") or die "Cannot open datafile: $!";
>> while (!eof(MESSAGE)) {
>>     $page = new CGI(MESSAGE);
>...more snippage
>> I get this
>> -RESULTS------------------------------------------
>> Bareword "MESSAGE" not allowed while "strict subs" in use at 
>> ./errorprog.pl
[snippage]
>Yep, I'm replying to my own post.
>
>I have now also determined that quoting the word 'MESSAGE' above
>e.g. open('MESSAGE', "$datafile")
>clears the error.  I guess use strict is trying to make sure I
>didn't actually mean to use some sort of variable.
>This is how I think I'll proceed in this case.  

Yuck.  If you need to pass a bareword filehandle, at least do it with a
glob ref so you can see what it's for:

        $page = new CGI(\*MESSAGE);

What's much easier than learning what the heck a glob ref is, though,
is using a lexical filehandle:

        open my $message, $datafile or die...
        $page = CGI->new($message);

which will work on any Perl from 5.6.0 on.

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http//www.perlmedic.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to