in reply to Identifiying unique pattern
If you're always looking for prefixes, then something like this may get you the pattern:
Then you just put a * at the end of whatever it returns. If you want to find the longest shared string, well, that would be a bit more difficult.sub prefix { my $prefix = shift; for (@_) { next if $prefix eq substr($_, 0, length $prefix); chop $prefix; redo; } $prefix; }
|
|---|