We don't bite newbies here... much | |
PerlMonks |
Re^2: Comparing multiple stringsby AnomalousMonk (Archbishop) |
on Jan 16, 2019 at 22:11 UTC ( [id://1228662]=note: print w/replies, xml ) | Need Help?? |
... a ... regex solution for this problem? Since the application seems to call for exact string matching, I would prefer a hash lookup or any-based solution as discussed already in this thread. But a regex solution might look like this: Since the regex is \A \z anchored for an exact match, the reverse sort step isn't really necessary, but it can't hurt. See Building Regex Alternations Dynamically. As to how fast it is, I leave that to your Benchmark-ing. My guess is that this approach should be fairly fast if you don't have to build the regex anew each time you do a set of comparisons; if you do, forget it. Give a man a fish: <%-{-{-{-<
In Section
Seekers of Perl Wisdom
|
|