Hi All,
I'm having trouble understanding what use strict is trying to tell me.

If I have run this program

-CODE---------------------------------------
#!/usr/bin/perl -wT
# use warnings and turn on data tainting
use CGI qw(:standard);
$CGI::POST_MAX=1024 * 100;
$CGI::DISABLE_UPLOADS = 1;
use strict;
use diagnostics;

# Declare Variables
my ( $datafile, $page );
$datafile="message.txt";

# Open message file and read in the contents
open(MESSAGE, "$datafile") or die "Cannot open datafile: $!";
while (!eof(MESSAGE)) {
    $page = new CGI(MESSAGE);
    print $page->param('message'),
          $page->br,"\n",
          "Submitted by: ",
          $page->param('person'),
          $page->br,"\n",
          "On: ",
          $page->param('dateposted'),
          $page->br,"\n";
}
-ENDCODE------------------------------------------

I get this

-RESULTS------------------------------------------
Bareword "MESSAGE" not allowed while "strict subs" in use at ./errorprog.pl
line 16 (#1)


(F) With "strict subs" in use, a bareword is only allowed as a
subroutine identifier, in curly brackets or to the left of the "=>" symbol.
Perhaps you need to predeclare a subroutine?


Execution of ./errorprog.pl aborted due to compilation errors (#2)

(F) The final summary message when a Perl compilation fails.

Uncaught exception from user code:
        Execution of ./errorprog.pl aborted due to compilation errors.
-ENDRESULTS-----------------------------------------

My questions are:

1) Why is it warning me at all? Using a bare word in the filehandle is common
in my Perl manuals. In this case a bare word does everything I need it to do.
What is this warning trying to prevent?


2) If I replace MESSAGE with $filehandlename and add $filehandlename to the my () block
it doesn't complain. If I do that I haven't assigned a value to $filehandlename.
Does that mean my filehandle is actually 'undef'?
That doesn't seem right somehow, especially if I have multiple files open in
a different circumstance. What value should I assign to $filehandlename? MESSAGE?



All comments appreciated. Brian


-- 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