Gossamer Forum
Home : General : Perl Programming :

Me again....objects....

Quote Reply
Me again....objects....
Sorry for all these posts - I'm definitely stuck with this one. (Not even my trusty perl book can help)

I want to use a %globals hash (created in the main script), in a module.

I create the object like:

$db = new Modules::Database (CFG => $cfg, TPL => $tpl, GLOBALS => \%globals);

Right, what I need to be able to do (for the sake of this example) is print all globals like you can do with a normal hash.

I can access individual globals like $self->{GLOBALS}->{KEY} but I can't seem to figure out how to access them all at once.

Ive tried:

%$self->{GLOBALS};

$self->{GLOBALS};

%$self->{GLOBALS}->{globals};

etc......

Could a guru please tell me how I access all keys :)

Thanks a lot.

Last edited by:

RedRum: Sep 30, 2001, 4:23 PM
Quote Reply
Re: [RedRum] Me again....objects.... In reply to
Are you looking to loop through the keys?

something like:
Code:
while (my ($key, $value) = each %{$self->{GLOBALS}}) {
# Stuff
}

is that what youi're looking for?

--mark
Quote Reply
Re: [Mark Badolato] Me again....objects.... In reply to
Thanks, that was just what I was looking for.

I tried %$self->{GLOBALS} but forgot about %{$self->{GLOBALS}}

Anyway thanks!

Last edited by:

RedRum: Sep 30, 2001, 7:23 PM
Quote Reply
Re: [Mark Badolato] Me again....objects.... In reply to
Mark,

Long time no see! Good to see you back!

Cheers

Wil
Quote Reply
Re: [Wil] Me again....objects.... In reply to
Hey Wil,

Not back.... I usually stop by and scan posts once a day or so. I just don't post too often anymore :)

--mark
Quote Reply
Re: [Mark Badolato] Me again....objects.... In reply to
You still with the UBB? I haven't been able to get into their site recently. When I enter the URL into my browser, a download dialogue box pops-up. Grrr.

Cheers

Wil
Quote Reply
Re: [Wil] Me again....objects.... In reply to
Yup, still there. The url may be different since last time you were there.

http://ubbforums.infopop.com/cgi-bin/ultimatebb.cgi
Quote Reply
Re: [Mark Badolato] Me again....objects.... In reply to
Thanks.