- or download this
$len = length($field);
$field1 = substr($field, 0, int($len/2));
$field2 = substr($field, -int($len/2));
$field = $field1 if ($field1 eq $field2);
- or download this
$field =~ s/^(.+)\s*\1/$1/;
- or download this
$field =~ s/(.{2,})\s*\1/$1/g;
- or download this
$field =~ s/\b(.+)\b\s*\1\b/$1/g;
- or download this
sub test1 {
my $len = length($_[0]);
...
John Johnson
foo John Johnson bar
John Smith!John Smith