#!perl use strict; use warnings; use Benchmark qw/ cmpthese /; my $s = "the quick brown fox\njumps over"; sub juerd { my ($foo) = @_; $foo =~ s/(.)$/uc $1/e; return $foo; } sub theguvnor { my ($foo) = @_; $foo = reverse ucfirst reverse $foo; return $foo; } sub seattlejohn { my($foo) = @_; substr( $foo, -1, 1 ) =~ tr/a-z/A-Z/; return $foo; } cmpthese( shift || -5, { 'juerd' => sub { juerd($s) }, 'theguvnor' => sub { theguvnor($s) }, 'seattlejohn' => sub { seattlejohn($s) }, });