sub findCycle { my $str = @_ ? shift : ''; $str =~ /^(.*?)\1*$/; return wantarray ? ( length $1, $1 ) : length $1; }