CGI and param() problem
am 05.12.2004 01:48:58 von Justin C
I kind of see what's going on but don't understand.
I have a web page that has three text boxes for numerical input, on
clicking the submit button the three inputs are passed a Perl script.
Instead of performing the task I get
Undefined subroutine &main::param called at dim-weight.pl line 10.
The web page is using method="get" and is passing:
[URL to script]?side1=80&side2=80&side3=80
to the Perl script. I think the reason for the error is the '&' in what's
being passed. I've tried method="post" but get the same error (but I don't
see what is passed to the script in the browser address box.
The script errors on line ten, here are the first ten lines (with comments
removed:
#!/usr/bin/perl -w
use strict ;
use CGI::Carp qw(fatalsToBrowser) ;
my $side1 = param("side1") ;
my $side2 = param("side2") ;
my $side3 = param("side3") ;
I've tried to follow what's in the Perl Cookbook (First Ed, P671) but they
only have one parameter.
Can someone point me at some documentation that'll help me out? "perldoc
-q param" and "perldoc -f param" turn up nothing, maybe I don't have all
of the docs installed?
Thanks for any help you can give.
--
Justin C, by the sea.
Re: CGI and param() problem
am 05.12.2004 10:05:59 von Tintin
"Justin C" wrote in message
news:pan.2004.12.05.00.48.57.988897@purestblue.com...
>
> I kind of see what's going on but don't understand.
>
> I have a web page that has three text boxes for numerical input, on
> clicking the submit button the three inputs are passed a Perl script.
> Instead of performing the task I get
> Undefined subroutine &main::param called at dim-weight.pl line 10.
> The web page is using method="get" and is passing:
> [URL to script]?side1=80&side2=80&side3=80
> to the Perl script. I think the reason for the error is the '&' in what's
> being passed. I've tried method="post" but get the same error (but I don't
> see what is passed to the script in the browser address box.
>
> The script errors on line ten, here are the first ten lines (with comments
> removed:
> #!/usr/bin/perl -w
>
> use strict ;
> use CGI::Carp qw(fatalsToBrowser) ;
>
> my $side1 = param("side1") ;
> my $side2 = param("side2") ;
> my $side3 = param("side3") ;
>
> I've tried to follow what's in the Perl Cookbook (First Ed, P671) but they
> only have one parameter.
Are you *absolutely* sure that's what is on that page?
You are missing the CGI module.
use CGI qw(:standard);
Re: CGI and param() problem
am 05.12.2004 19:35:05 von Justin C
On Sun, 05 Dec 2004 22:05:59 +1300, Tintin wrote:
>
> "Justin C" wrote in message
> news:pan.2004.12.05.00.48.57.988897@purestblue.com...
>>
>> I kind of see what's going on but don't understand.
>>
[snip]
>> #!/usr/bin/perl -w
>>
>> use strict ;
>> use CGI::Carp qw(fatalsToBrowser) ;
>>
>
> Are you *absolutely* sure that's what is on that page?
>
> You are missing the CGI module.
>
> use CGI qw(:standard);
Oh. You need that too? Is 'CGI' not the module and ::Carp some method of
calling it then? I've not done that much Perl and modules are something
I've tried to avoid (there are so many of them I rarely know where to
start... as is obvious!).
..
..
..
Oh yes, that's fixed it. Thanks for that, will add it to my list of Perl
notes.
--
Justin C, by the sea.
Re: CGI and param() problem
am 05.12.2004 20:08:29 von Tintin
"Justin C" wrote in message
news:pan.2004.12.05.18.35.05.44225@purestblue.com...
> On Sun, 05 Dec 2004 22:05:59 +1300, Tintin wrote:
>
>>
>> "Justin C" wrote in message
>> news:pan.2004.12.05.00.48.57.988897@purestblue.com...
>>>
>>> I kind of see what's going on but don't understand.
>>>
> [snip]
>>> #!/usr/bin/perl -w
>>>
>>> use strict ;
>>> use CGI::Carp qw(fatalsToBrowser) ;
>>>
>>
>> Are you *absolutely* sure that's what is on that page?
>>
>> You are missing the CGI module.
>>
>> use CGI qw(:standard);
>
> Oh. You need that too? Is 'CGI' not the module and ::Carp some method of
> calling it then? I've not done that much Perl and modules are something
> I've tried to avoid (there are so many of them I rarely know where to
> start... as is obvious!).
CGI::Carp is a seperate (but related, hence being in the CGI heirarachy)
module. Methods are unique to the particular module being 'use'd.
Re: CGI and param() problem
am 05.12.2004 20:45:04 von Matt Garrish
"Justin C" wrote in message
news:pan.2004.12.05.18.35.05.44225@purestblue.com...
> On Sun, 05 Dec 2004 22:05:59 +1300, Tintin wrote:
>
>>
>> "Justin C" wrote in message
>> news:pan.2004.12.05.00.48.57.988897@purestblue.com...
>>>
>>> I kind of see what's going on but don't understand.
>>>
> [snip]
>>> #!/usr/bin/perl -w
>>>
>>> use strict ;
>>> use CGI::Carp qw(fatalsToBrowser) ;
>>>
>>
>> Are you *absolutely* sure that's what is on that page?
>>
>> You are missing the CGI module.
>>
>> use CGI qw(:standard);
>
> Oh. You need that too? Is 'CGI' not the module and ::Carp some method of
> calling it then? I've not done that much Perl and modules are something
> I've tried to avoid (there are so many of them I rarely know where to
> start... as is obvious!).
>
If you want a very simplistic explanation, think of the :: part of a module
name as indicating the directory structure. As an example:
use CGI;
Means that in the root of (one of) your library directories is a file called
CGI.pm whose methods/properties/etc. you want to include:
../CGI.pm
Likewise, CGI::Carp would be in a subdirectory called CGI off of the root:
../CGI/Carp.pm
You shouldn't think of the two as necessarily being related, though. The
relation may only be by name, as in this case (i.e., both are of use for CGI
programming, but share nothing else in common).
There are also times when the two are related, and you can call
methods/properties in the parent from the child, but you have to read the
documentation to find that out.
A more expansive explanation can be found by reading perlmod, perltoot, etc.
Matt
Re: CGI and param() problem
am 06.12.2004 01:47:57 von Justin C
On Sun, 05 Dec 2004 14:45:04 -0500, Matt Garrish wrote:
[snip]
>
> If you want a very simplistic explanation, think of the :: part of a module
> name as indicating the directory structure. As an example:
>
> use CGI;
>
> Means that in the root of (one of) your library directories is a file called
> CGI.pm whose methods/properties/etc. you want to include:
>
> ./CGI.pm
>
> Likewise, CGI::Carp would be in a subdirectory called CGI off of the root:
>
> ./CGI/Carp.pm
>
> You shouldn't think of the two as necessarily being related, though. The
> relation may only be by name, as in this case (i.e., both are of use for CGI
> programming, but share nothing else in common).
I've a lot more to learn about Perl modules!
I wish I had more problems that I could solve using Perl so I could learn
it better (really I don't want *any* problems but they come along from
time to time and that's no way to stay focused on what can and can't be
done - hey ho, what can you don?)
Thank you for the help.
--
Justin C, by the sea.