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

Calling a global from a global???

Quote Reply
Calling a global from a global???
Hi there Wink

I have searched on google and through the forums for this one.
Is it possible to call one global from another eg.

Code:

global1 sub { return "hehe"; }

global2 sub {return global1;}

When I try this, the template I use <%global2%> in, complains that global1 doesn't exist...Frown

Thanks.


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] Calling a global from a global??? In reply to
Hi,

Only way I know of how to do it (appart from putting into the Custom.pm file and calling with Custom::func_name()), is to do like so:

Code:
sub {

my $val = other_sub_inside();

sub other_sub_inside {
# do something here
}

}

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Calling a global from a global??? In reply to
Ok, thanks Andy Smile


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] Calling a global from a global??? In reply to
You can load the globals file, ie:

Code:
sub {
local $@;
my $globals = do "/path/to/globals.txt" or return "Unable to load globals: $!";
my $out = eval "$globals->{your_other_global}";
return $out->() if (! $@ && ref($out) eq 'CODE') ;
return "Compilation of global failed: $@";
}

The globals file may already be stored in memory so you may not need to load it - there might be a global variable holding it somewhere. I've not checked.

Last edited by:

Wychwood: May 21, 2008, 1:42 AM