in reply to Palindrome Program without Reverse function

A word is a palindrome if it's either the empty string, a string of one character, or if it's a palindrome proceeded and succeeded by the same character. So, I present you the following, untested, subroutine:
my is_palindrome {length($_[0])<2||substr($_[0],0,1) eq substr($_[0],- +1,1)&&is_palindrome(substr($_[0],1,-1);}

Replies are listed 'Best First'.
Re^2: Palindrome Program without Reverse function
by choroba (Cardinal) on Oct 31, 2011 at 12:32 UTC
    Tested, fixed: sub is_palindrome {length($_[0])<2||substr($_[0],0,1) eq substr($_[0],-1,1)&&is_palindrome(substr($_[0],1,-1))}