[RADIATOR] Define a global array

Steve Phillips steve at focb.co.nz
Tue Apr 1 20:03:13 CDT 2014


Actually, flag that - I found why it wasn't working and it was me 
failing at perl.

&main::setVariable($varName.$key, $columns{$key});

should have been

&main::setVariable($varName . "." . $key, $columns{$key});

-- 
Steve.

On 2/04/2014 11:56 am, Steve Phillips wrote:
> Hey Hugh,
>
> Yep, had a look through there but can't see how you'd use this to set an
> array variable, or would &main::setVariable allow you to set a complex
> variable (a hashed array for example) as opposed to a simple singular
> variable?
>
> I've sort of got this working to set a value based on what was listed in
> the hooks.txt and fudging something together using a loop, the keys
> directive and setting a prefix to the key so I end up with
>
> &main::setVariable(global_steve.message1,"value")
> &main::setVariable(global_steve.message2,"value2")
>
> And then referencing it with
>
> my $string = "Test: " . &main::getVariable('global_steve.'.$myMessage);
>
> (which doesn't work :-( )
>
> (I'm trying to do &main::log($main::LOG_INFO,
> &main::getVariable($blerg)); where $blerg is defined as;
>
> my $blerg = "global_steve.$someAttribute";
>
> and $someAttribute is either message1 or message2
>
> )
>
> I'm also picking that &main::setVariable(global_steve{message1}) isn't
> going to work either, but I guess I'll try that next.
>
> Is there any way at all to get a hashed array available globally?
>
> Of interest, when I set the variable in the first hook as follows
>
> foreach my $key (keys %columns) {
>
>     &main::log($main::LOG_DEBUG,"setVariable $varName.$key =
> $columns{$key}");
>     &main::setVariable($varName.$key, $columns{$key});
>     &main::log($main::LOG_DEBUG,&main::setVariable($varName.$key,
> $columns{$key}));
>
> }
>
> It seems to print out to the logs the expected values, but when I use
> the exact same &main::log line in the PreHandler hook it doesn't, it's
> almost as if it's forgotten the variable set in the previous startup hook?
>



More information about the radiator mailing list