in reply to Re: using a hash to do substitution?
in thread using a hash to do substitution?
That is, the longer keys will appear first in the alternatives list and thus they will be matched first.$regex = join("|", map(quotemeta, sort { length $b <=> length $a } keys %hash)); s/($regex)/$hash{$1}/eg;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: using a hash to do substitution?
by dimmesdale (Friar) on Jun 15, 2001 at 00:18 UTC |