$_ = ; $_ = $` if /$/; @a = split //, $_; for $i (0 .. $#a){ $e = $a[$i]; $hash{$e} = 1; for $y ($i+1 .. $#a){ $e .= $a[$y]; $hash{$e} = 1; } } while(){ $_ = $` if /$/; @a = split //, $_; %thash = (); for $i (0 .. $#a){ $e = $a[$i]; $thash{$e} = 1 if defined $hash{$e}; for $y ($i+1 .. $#a){ $e .= $a[$y]; $thash{$e} = 1 if defined $hash{$e}; } } foreach $key (keys %hash){ $hash{$key}++ if defined $thash{$key}; } } $max = ''; foreach $key (keys %hash){ if($hash{$key} == 3){ $max = $key if length($max) < length($key); } } print "$max\n"; __DATA__ strrringggg ssttrrringggg stttrrringgg