Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Can't use string ("1") as a HASH ref while "strict refs" in use at (eval 27) line 7.

Quote Reply
Can't use string ("1") as a HASH ref while "strict refs" in use at (eval 27) line 7.
Anyone got any ideas why I'm getting this error;

Quote:
Can't use string ("1") as a HASH ref while "strict refs" in use at (eval 27) line 7.


The code is;

Code:
my $tags = shift;
my $CatID = $tags->{ID};

If I comment out the second line, it works fine (well, it doesn't, but I don't get an error).

I'm sure I've had this problem before... but I can't seem to work out how to fix it Frown

Any help is much 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] Can't use string ("1") as a HASH ref while "strict refs" in use at (eval 27) line 7. In reply to
What is the code before the snippet you posted? If it is a sub or global, how do you call it?

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Can't use string ("1") as a HASH ref while "strict refs" in use at (eval 27) line 7. In reply to
Hi yogi. Thanks for the reply.

Its just a global. The first bit of it is;

Code:
sub {

use LWP::Simple;
use XML::Simple;

my $tags = shift;
my $CatID = $tags->{ID};

my $table = $DB->table('Category');
my $sth = $table->select( { ID => $CatID } );
my $Keyword;

while (my $hit = $sth->fetchrow_hashref) {
$Keyword = $hit->{Keyword};
}

Its called with;

<%global_name($ID)%>

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] Can't use string ("1") as a HASH ref while "strict refs" in use at (eval 27) line 7. In reply to
Weeeeeel, of course this wouldn't work.

You are passing a scalar to the sub, and then you want to dereference the scalar....

In other words, just use

my $CatID = shift;

and leave out the my $tags bit.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Can't use string ("1") as a HASH ref while "strict refs" in use at (eval 27) line 7. In reply to
Thanks . I don't need to use this function any more, because of the other thread you helped me in. I was basically trying to validate if any results existed, and if so, then show the HTML codes...

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!