There's more than one way to do things | |
PerlMonks |
Re: Testing for the presence of a hash key in a filenameby benizi (Hermit) |
on May 27, 2007 at 18:23 UTC ( [id://617755]=note: print w/replies, xml ) | Need Help?? |
It appears from the problem description that the keys are all three characters, but just as a heads-up, you might want to add a reverse to that: my $match = '('.join('|', reverse sort keys %replace).')'; The reverse ensures that the longest match is found even if some pattern is a prefix of another (which, in my experience, is generally the desired outcome). e.g.:
Should print:
In Section
Seekers of Perl Wisdom
|
|