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*", ...; ...; }