in reply to how to let sub return hash of 2 sub?

With a bit of extra syntax, you don't have to use objects. :-)

#!/usr/bin/env perl use 5.010; use strict; use warnings; # a closure over a hash which takes a key as an argument and returns t +wo subs # which return the key and its value from the hash sub get_caller { my $h = shift; return { parameter => sub { my $k = shift; my $v = $h->{$k}; return { name => sub { return $k }, val => sub { return $v } }; } }; } my $c = get_caller( {'a.x' => 1, 'b.y' => 2, 'c.x' => 3} ); print $_->{name}(), ' : ', $_->{val}(), "\n" for $c->{parameter}('a.x' +);

I think it would be possible to get rid of some of the curlies and parens and get it down to the simpler syntax of the original, but I'm still working through Higher Order Perl. This "functions that create functions to return functions" stuff gets a little mind-bending.

Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.