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 ); } }