in reply to Re^2: Avoid run-time checking
in thread Avoid run-time checking

Using table approach seems viable, but I don't like to separate subroutine and template string in different places if possible.

:) All approaches are viable, it will always come down to your prejudice/bias/choice :D

so type up a few 1-3 subs of each and then compare/contrast what you like about each

my %templates; $templates{big}{foo} = 'v3A*'; $templates{lil}{foo} = 'n3A*'; $templates{big}{bar} = 'v2A*'; $templates{lil}{bar} = 'n2A*'; sub record_foo { my( $end, ... ) = ; my @res = unpack $templates{$end}{foo}, ...; ...; } sub record_bar { my( $end, ... ) = ; my @res = unpack $templates{$end}{foo}, ...; ...; } %templates = ( big => { bar => "v2A*", foo => "v3A*", }, lil => { bar => "n2A*", foo => "n3A*", }, ); sub record_foo { my( $big, ... ) = ; my @res = unpack $big? "v3A*" : "n3A*", ...; ...; } sub record_bar { my( $big, ... ) = ; my @res = unpack $big? "v2A*" : "n2A*", ...; ...; }