- or download this
my (@str1, @str2);
my ($i, @prefix) = (0);
...
last if $_ ne $str2[$i++];
push @prefix, $_;
}
- or download this
my (@str1, @str2);
my ($i, @prefix) = (0);
push @prefix, $str1[$i++] while($str1[$i] eq $str2[$i]);
- or download this
my ($s1, $s2) = ("ABCD", "ABEF");
my $i = 0;
$i++ while substr($s1, $i, 1) eq substr($s2, $i, 1);
my $prefix = substr $s1, 0, $i;