sub rec_reverse { my $problem = shift; if( $problem eq '' or ! defined $problem ) { return $problem; # Can't be made smaller. End case. } else { my( $char, $smaller_problem ) = $problem =~ m/\A(.)(.*)\z/s; return rec_reverse( $smaller_problem ) . $char; } }