my %functions_hash = ( '\.vms' => sub { $_[0] =~ s{/}{} } ); ... if ( $data =~ /$key/ ) { $value->( $data ); }