Dermot wrote:
> sub someFunc {
>     use Data::Dumper;
>     print STDERR Dumper(@_);
>     print STDERR "Last el=". ref($_[-1])."\n";
>     my $args = (ref($_[-1]) eq 'HASH') ? pop : @_;
>     foreach (keys %{$args}) {
>         print STDERR "someFunc: $args->{$_} => $_\n";
>     }
> }
> I have a problem now in that the function is used elsewhere but called as
> SomeMod::someFunc(lid=>$lid, perpage=>'12').
> 
> I want to maintain that compatibility. I'll need to coerce the
> reference into an normal hash or vice-verse. I guess that's a question
> for another list.

Your function is slightly wrong. Try this:
my $args = (ref($_[-1]) eq 'HASH') ? pop : { @_ };

The way you had it, you were simply storing the NUMBER of arguments to $args if 
a hashref wasn't passed. You need to convert the parameters to a hashref.

-- Josh

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

Reply via email to