Gossamer Forum
Home : General : Perl Programming :

Hash help...!

Quote Reply
Hash help...!
I very rarely need to use hashes, but here I am. I have the following code;

Code:
my $values = $IN->get_hash;

if ($IN->param('midi') ne "NONE") {
$values{'BackgroundMusic'} = $IN->param('midi');
} else { $values{'BackgroundMusic'} = ""; }

However, this gives an error;

Quote:
Software error:

Global symbol "%values" requires explicit package name at /home/cgi-bin/ecards/ecard_send.cgi line 36.
Global symbol "%values" requires explicit package name at /home/cgi-bin/ecards/ecard_send.cgi line 37.
Execution of /home/cgi-bin/ecards/ecard_send.cgi aborted due to compilation errors.

What am I doing wrong? As far as I can see, %values is already defined Unsure I'm thinking it may have something to do with the difference between %values and $value....but doesn't $value hold a hash?

Any help is appreciated :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Hash help...! In reply to
>>
%values is already defined
<<

No $values is defined and $values is a hashref not a hash. You are also calling $IN->param() when you already have everything you need in the hashref.

Code:
my $values = $IN->get_hash;

$values->{BackgroundMusic} = $values->{midi} unless ($values->{midi} eq "NONE");
Quote Reply
Re: [Paul] Hash help...! In reply to
Still giving an error, even with your code Unsure

Global symbol "%values" requires explicit package name at /home/cgi-bin/ecards/ecard_send.cgi line 36.
Global symbol "%values" requires explicit package name at /home/cgi-bin/ecards/ecard_send.cgi line 37.

Any ideas?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Hash help...! In reply to
The code I gave was fine. You must have used $values{blah} instead of $values->{bla}

Last edited by:

Paul: Dec 24, 2002, 10:29 AM