On 12/12/06, Helliwell, Kim [EMAIL PROTECTED] wrote:
Is there a function (perhaps in a library module) that would take two
strings and return the common substring (if any) contained in the
arguments?
You want the longest possible common substring? Or all of the longest
ones, if there's more
Helliwell, Kim wrote:
Is there a function (perhaps in a library module) that would take two
strings and return the common substring (if any) contained in the
arguments? I've been looking for such a beast on CPAN, but no luck so
far.
Perhaps this is what you require:
Helliwell, Kim am Dienstag, 12. Dezember 2006 21:56:
Is there a function (perhaps in a library module) that would take two
strings and return the common substring (if any) contained in the
arguments? I've been looking for such a beast on CPAN, but no luck so
far.
If not, I guess I have to
On 12/12/06, D. Bolliger [EMAIL PROTECTED] wrote:
$found{$1}++ for ($s2=~/($search)/g); # although count not used below
Didn't $search just come from the data? It's a string, not a pattern.
If it's got any metacharacters, it could break your pattern, or worse.
Cheers!
--Tom Phoenix
Tom Phoenix am Mittwoch, 13. Dezember 2006 02:32:
On 12/12/06, D. Bolliger [EMAIL PROTECTED] wrote:
$found{$1}++ for ($s2=~/($search)/g); # although count not used
below
Didn't $search just come from the data? It's a string, not a pattern.
If it's got any metacharacters, it could
D. Bolliger am Mittwoch, 13. Dezember 2006 02:25:
Sorry for answering my own post...
[snipped]
The script contains a testcase with long strings, it takes 1.2 secs on my
old machine (the test case is certainly not a worst case scenario).
[snipped]
### Test case:
my $pat=join '', 'hello' x