Gossamer Forum
Home : General : Perl Programming :

Newbie Help with eplicit package name

Quote Reply
Newbie Help with eplicit package name
Hi,

I am a newbie at this whole Perl thing. Can someone help me out with these following errors? Below the errors is the script that I am writing.

Thanks
K.

----

Global symbol "%qx" requires explicit package name at /home/virtual_hosts/www-test.xyz.com/cgi-bin/register line 38.
Global symbol "$short_quark" requires explicit package name at /home/virtual_hosts/www-test.xyz.com/cgi-bin/register line 56.
Global symbol "%qx" requires explicit package name at /home/virtual_hosts/www-test.xyz.com/cgi-bin/register line 56.
Global symbol "$short_quark" requires explicit package name at /home/virtual_hosts/www-test.xyz.com/cgi-bin/register line 120.
Execution of /home/virtual_hosts/www-test.xyz.com/cgi-bin/register aborted due to compilation errors.

----

#!/usr/bin/perl -wT
# This script registers
# Lasted Revised 2003-05-03

use strict;

my $version = param("version");
my $serial = param("serial");
my $release = param("release");
my $os = param("os");
my $quark = param("quark");
my $name = param("name");
my $title = param("title");
my $company = param("company");
my $address = param("address");
my $city = param("city");
my $state = param("state");
my $zip = param("zip");
my $country = param("country");
my $phone = param("phone");
my $fax = param("fax");
my $email = param("email");
my $fromwhom = param("fromwhom");
my $mm = param("mm");
my $dd = param("dd");
my $yy = param("yy");
my $business = param("business");
my $otherbusiness = param("otherbusiness");
my $job = param("job");
my $otherjob = param("otherjob");
my $howlearn = param("howlearn");
my $otherlearn = param("otherlearn");
my $veps = param("veps");
my $spam = param("spam");
my $delivery = param("delivery");
my $comments = param("comments");

%qx = ("ppc3.32","332P",
"ppc4.02","402P",
"ppc4.03","403P",
"ppc4.04","404P",
"ppc4.1","410P",
"ppc4.11","411P",
"68k_3.32","332K",
"68k_4.02","402K",
"68k_4.03","403K",
"68k_4.04","404K",
"68k_4.1","410K",
"68k_4.11","411K",
"Wintel_4.03","403W",
"Wintel_4.04","404W",
"Wintel_4.1","410W",
"Wintel_4.11","411W",
"null","0000");

$short_quark = $qx{$quark};
Quote Reply
Re: [kfuruta] Newbie Help with eplicit package name In reply to
Eek.

You are using "strict" but aren't declaring all your variables with my()

Regarding that huge list of my()'s you have, you'd be far better creating a subroutine to map all the parameters into a hash or something so you can do:

my %params = _load_params();

Then you can do stuff like:

$param{version}
Quote Reply
Re: [kfuruta] Newbie Help with eplicit package name In reply to
your forgot to declare your last two variables with "my".

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [kfuruta] Newbie Help with eplicit package name In reply to
Hi,

Thanks for giving me that help. I put the "my" in front of the 2 variables that didn't have it....and that seemed to take away one error. Now, another one has popped up.

-----
Undefined subroutine &main::param called at /home/virtual_hosts/www-test.xyz.com/cgi-bin/register line 7.
-----

Line 7 being the first variable in the script.

I apologize for the inane quality of this post....I really am just beginning on this stuff.

Thanks,
K.
Quote Reply
Re: [kfuruta] Newbie Help with eplicit package name In reply to
You are using param() which is a sub-routine exported from CGI.pm, so you need to "use" it.

use CGI qw/:standard/;

perldoc.com is a site you need to bookmark.
Quote Reply
Re: [Paul] Newbie Help with eplicit package name In reply to
In Reply To:
Eek.

...
my %params = _load_params();

Then you can do stuff like:

$param{version}


I'm brand spanking new to this forum, today, and I love the tone and quality of it. Hope I'm not out of line Shocked by mentioning an error in the above example:

my %params = _load_params();

Then you can do stuff like:

$param{version} # This should read: $params{version}

Or make hash singlular, which I prefer:

my %param = _load_params(); # singular hash

Then you can do stuff like:

$param{version}