sub rot { my $str = shift; my $rot = (shift) % length($str); # to rotate more than once $str =~ s/(.{$rot})(.*)/$2$1/; $str; }