in reply to Re: Re: using a hash to do substitution?
in thread using a hash to do substitution?
This way, you cut the expense of alteration (if the keys are user defined, or you have metachars in them, instead of quotemeta, add \Q and \E before and after, respectively, the first $_ in the substitution). You can print $code to test its values, and by doing it can easily customize it for your specific needs(though if substituting is the only thing going on, this won't be a concern).$code .= map { "s/\b$_\b/$hash{$_}/eg;\n" } keys %hash; eval $code;
|
|---|