sub rot_same { my( $word )= @_; my %seen; for(1..length $word) { ## rotate right $word= chop($word) . $word; return 1 if exists $seen{$word}; $seen{$word}++; } } print $_, ' => ', rot_same($_), $/ for qw(abcdef aaaaaa abcabc); __END__ abcdef => aaaaaa => 1 abcabc => 1