RosettaCodeData/Task/Longest-common-subsequence/Perl/longest-common-subsequence-2.pl
2023-07-01 13:44:08 -04:00

16 lines
334 B
Perl

use strict;
use warnings;
use feature 'bitwise';
print "lcs is ", lcs('thisisatest', 'testing123testing'), "\n";
sub lcs
{
my ($c, $d) = @_;
for my $len ( reverse 1 .. length($c &. $d) )
{
"$c\n$d" =~ join '.*', ('(.)') x $len, "\n", map "\\$_", 1 .. $len and
return join '', @{^CAPTURE};
}
return '';
}