Mike's Pub -> Discussion Corner -> Support Forum for aWebVisit

 Global symbol "@pairs" requires explicit package name [ Reply ] [ Back to Index ] Top Bottom

Author : Sandra
Date: 2003/05/23 20:49

Mike, I'm very new to Perl/CGI scripting and basically sitting here teaching myself.  I've
done a mailing script that'll capture and email the results from a form input (using html)
to recipients email.

I could've gone the easy route by using pre-formatted perl scripts but I don't think I
would gain much from that, so I bought myself Programming Perl and wearing myself out to
no ends. :)

I'm now getting errors when I decided to use some thing called use strict; --- and the
errors I'm getting are "Global symbol @pairs requires explicit package name". 

How can I fix these errors?  What should I be looking at?

I have a sub routine for sub parsing_form and in this I have @pairs mentioned e.g., 
@pairs = split(/&/, $ENV{'QUERY_STRING'});

but this is just one of many lines that @pairs is used.

Should I declare @pairs before the sub routine?  How do I declare @pairs?  Would it be
doing some thing such as this
  my @pairs = use CGI;

Excuse my multiple questions but I'm very new to this and it's real important that I have
some fair understanding how perl/cgi works.

Thanks for your time.

 Re: Global symbol "@pairs" requires explicit package name [ Reply ] [ Back to Index ] Top Bottom

Author : Mike
Date: 2003/06/04 16:40

use strict; is a highly recommended setting when you want to learn about your mistakes as
soon as possible :)

use CGI; is another highly recommended module if you want to avoid the thousands of common
mistakes (not to mention security holes) that people create when they try to roll their
own CGI parsing code.

The best way to learn (other than following the Programming Perl book) is to read the
documentation that comes with perl itself. It's either available as HTML pages when you
install ActivePerl, or you can call it up directly with perldoc.

For instance, there are some good examples on how to retrieve CGI parameters in the CGI
documentation.

For mail forms, you should also be extra careful not to accept *anything* that might be
used to overwrite your own configuration, and so leave your script open to be used by
spammers all over the world.

In this particular case, a good starting point would also be to analyse the FormMail
alternative written by the nms team at http://nms-cgi.sourceforge.net/scripts.shtml - it's
a total rewrite of Matt Wright's original script, with security and clean code in mind...

P.S.: and since you posted this in the aWebVisit forum, don't try to use strict; or -w in
aWebVisit, because you'll get hundreds of warnings and errors - not a good way to learn
:)

 Reply [ Back to Index ] Top Bottom
Name : or OpenID OpenID Login
E-mail : (optional)
Subject :
Message :
MathGuard security question: 5 + 9 =
 

Mike's Pub -> Discussion Corner -> Support Forum for aWebVisit