# # Generate regex code from hash (untested) # my $code; foreach my $key (keys %const_hash) { $code .= qq( \$const =~ s/$key/$$const_hash{$key}/;\n ); } my $const = 'fill string here'; eval $code; die $@ if $@; # die on error