#!/usr/local/bin/perl -w use Benchmark; @long = ('a' x 100, 45); @short = ('a' x 10, 7); timethese( -10, { L_ariels => sub { ariels(@long) }, L_merlyn => sub { merlyn(@long) }, L_nashdj => sub { nashdj(@long) }, S_ariels => sub { ariels(@short) }, S_merlyn => sub { merlyn(@short) }, S_nashdj => sub { nashdj(@short) }, } ); sub ariels { my ($str, $rot) = @_; scalar reverse ((reverse substr($str,0,$rot)) . (reverse substr($str,$rot)) ); } sub merlyn { my ($str, $rot) = @_; substr($str,$rot) . substr($str, 0, $rot); } sub nashdj { my ($str, $rot) = @_; $str =~ s/(.{$rot})(.*)/$2$1/s; $str; }