
sub repeated_substring {
	my $string = shift;
	for (my $length = int(length($string) / 2); $length; $length--) {
		my $index = length($string) - 2 * $length;
		return $1 if $string =~ /^.{0,$index}?(.{$length}).*?\1/;
	}
	return '';
}
