Skip to content

Instantly share code, notes, and snippets.

@perlmonger42
Created August 16, 2012 20:25
Show Gist options
  • Save perlmonger42/3373357 to your computer and use it in GitHub Desktop.
Save perlmonger42/3373357 to your computer and use it in GitHub Desktop.
reverse_string(STRING): return a reversed copy of the input string
# Normally, you'd just say
# reverse STRING
# since Perl provides a builtin for this functionality, but that would be
# cheating based on the rules of the assignment.
# my $desrever = reverse_string(STRING);
#
# Return a reversed copy of the input string.
sub reverse_string {
return join '', reverse split //, $_[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment