Well, how do you as a human know which pattern to use?
Encode the same criterion in your program.
Maybe you meant to direct to the "most specific" pattern. Then just sort the patterns according to their specificity:
my @sorted_patterns = sort { my $spec_a = ($a =~ tr[.][.]); my $spec_b = ($b =~ tr[.][.]); $spec_b <=> $spec_a || $a cmp $b } @patterns;
In reply to Re^3: Longest match finding.
by Corion
in thread Longest match finding.
by rrboloor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |