Phillip Bruce wrote:
Wiggins d'Anconia wrote:

In the following line you need a 'my' to give the variable scope....

$mail = Mail::Internet->new(Header => $head,
                            Body   => [$body],
                            Modify => 1);


Ok, I did that and now I'm getting this error

 ./survey.cgi
Content-type: text/html

Undefined subroutine &main::param called at ./survey.cgi line 12.

So that is referenceing the following line my code:

my $customer = param("Customer");

So does Customer in the param setting needs to be $Customer maybe?


This error is telling you that the compiler can't find the 'param' subroutine in the 'main' package. The key here is that the 'param' subroutine is part of the CGI package which you should (and with experience) know. So the question becomes how do I get 'param' to work in my script when I have already done a


use CGI;

at the top. Without going into details about 'import', etc. read:

perldoc perlsub
perldoc perlmod

for more.

Essentially you should revisit the section on "Programming Style" in the CGI.pm docs, in particular the statement:

"The main differences are that we now need to import a set of functions into our name space (usually the "standard" functions), and we don't need to create the CGI object."

So since you are not using the OOP interface to CGI, you need to tell Perl to bring the functions into the local namespace so you can use them in the way you are, so something like:

use CGI qw/:standard/; # load standard CGI routines

Should help matters greatly. There are two other options, switch to the OOP interface and request a new CGI object then call the function (now a method) on the object instance, or practice your typing by including the full name everywhere:

my $customer = CGI::param('Customer');

Be sure to undersand what and how :standard works, and what other options are available.

http://danconia.org


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to