[Templates] Getting keys from a hash
Simon Wistow
simon at thegestalt.org
Tue Feb 26 11:33:02 GMT 2008
On Tue, Feb 26, 2008 at 11:17:44AM +0000, Karl Dane said:
> Right! So - there's something REALLY weird going on here...
>
> To answer Simon, cgihash is from perl's CGI lib: my $cgi = new CGI; my
> $cgihash = $cgi->Vars;
>
> Shouldn't be anything odd about it. But obviously it's behaving
> differently for some reason.
Ahah!
Right, from CGI.pm's docs
The Vars() method does this. Called in a scalar
context, it returns the parameter list as a tied hash reference.
Changing a key changes the value of the parameter in the
underlying CGI parameter list. Called in a list context, it returns
the parameter list as an ordinary hash. This allows you to read the
contents of the parameter list, but not to change it.
So you probably want to pass it in to TT as
my %params = (
cgihash => {%{$cgi->Vars}},
);
or similar.
Simon
More information about the templates
mailing list