my %DISPATCH = ( html => \&html, htm => \&html, pl => \&pl, cfm => \&cfm, ); $_ = '/path/to/file.ext'; $_ =~ /\.(\w+)\z/; $DISPATCH{$1}->($_, @other_args) if exists $DISPATCH{$1}; sub html { . . . } sub pl { . . . } sub cfm { . . . }