Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Accessing a global from within a script

Quote Reply
Accessing a global from within a script
HI there,

Is it possible to do something like this:

my $tags = GT::Template->tags;
my $select_fields = $tags->{build_select_fields};
my $state_select = $select_fields->{state_select}

I have a script, and I need to get the results of a global.

$select_fields comes back as CODE(0x87a38a4) using this method.
The code normally returns a hash of data from which I want to access a return variable called "state_select",
but I don't seem to be able to run the code from within a script and get values back.

Thanks in advance for any ideas?

peace.
Quote Reply
Re: [klangan] Accessing a global from within a script In reply to
That's a code reference for the global tag.

Use:

$select_fields->()

...to execute the code and return the value. eg...

my $returned = $select_fields->();