Hi All,

 

Can someone please let me know how to pass hashes from template to Perl?

 

I'd like to pass hashes to Perl subroutine to process things then return the
results back to template.

 

I tried something like this but it didn't work:

[% result(a => "1", b => "2") %]

 

Perl TT config:

my $config = {

            VARIABLES => {

                        result => \&calculate,

            },

};

 

Perl subroutine:

sub calculate {

my (@args) = @_;

return $args{a} + $args{b} if @args;

}

 

It's working if I tried this but I'm not preferred:

[% result("a", "1", "b", "2") %]

 

Thanks,

Chakkit

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to