in reply to Re: tied hash for data munging
in thread tied hash for data munging

Maybe I'm missing something?

Hell yes - the YAGNI part of it, which is the code generation, and the variable binding (which can be used for closures in the generating sub):

my $config = Config::Tiny->read($inifile); for my $key (keys %$config){ my $section = $config->{$key}; my $record; tie my %h, 'Sub::Hash', $gensub, $record; # $record bound %h = %{$section}; # transforms all INI file values # from this section into CODE refs my $result = getData( delete $h{SOURCE} ); for $record (values %$result) { write_csv( my %out = %h ); } }

This replaces an awful lot of code - which, I admit, could also be hidden in subroutines.

update:

Well, not so much really. Of course the subroutine table could also be set up as

%h = map { $_, $gensub->( $section->{$_} ) } keys %$section;

But the point of the whole thing is to have all that encapsulated in a single tied hash, which is arguably not so great an a good idea.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'