in reply to Re: regex question
in thread regex question
That's actually a really nice way to use a hash to look through a string and replace keys with values.
You could even generalize it to multi-character keys:
my %value_lkup = ( A => '1000', B => '2000', CDE => '3000', ); my $pat = '(?:' . join('|', keys %value_lkup) . ')'; s/($pat)/$value_lkup{$1}/g;
In Section
Seekers of Perl Wisdom