On Tue, 29 May 2001, David Gilden wrote:
> After adding:
> ' use strict; '
> and am now getting several warnings..
>
> In my library I have %FORM_DATA declared,
>
> File "hd:Perl:Cgi class:useractive:guest book:guestin.pl";
> Line 9: Global symbol "FORM_DATA" requires explicit package name.
>
> How can I avoid the above warning?
>
>
> #!/usr/bin/perl -w
> # CGI Script
> use strict;
>
> require "libcgi2.pl";
>
> &parse_input; # sub in our library
>
> #strip leading or trailing white space from all our form elements
> foreach my $key (keys %FORM_DATA){
> $FORM_DATA{$key} =~ s/^\s+|\s+$//g;
> }
%FORM_DATA (which I am guessing is defined and/or created in libcgi2.pl)
isn't explicitly put into a package (which you correctly do with the $key
scalar, using 'my'). Since you are requiring the library, it is getting
included into the current file, for which you are usng the strict pragma,
but it's complaining about things in the library that are not properly
defined using the stricter syntax.
Want to make your life easier? Use CGI.pm. It handles all of this form
input stuff for you automatically, and many other things besides, and
lets you focus more on your application logic than trying to decode
headers, HTML parsing, etc. And then send email to
[EMAIL PROTECTED] so you can get on the beginning Perl CGI
for beginners list.
-- Brett
Brett W. McCoy
Software Engineer
Broadsoft, Inc.
240-364-5225
[EMAIL PROTECTED]