use strict; my $string1 = "abcba"; my $string2 = "abc1da"; if (&reverser($string1)){ print "Matched! Strings are palindromes.\n"; } else{ print "Sorry, the strings are not palindromes.\n"; } if (&reverser($string2)){ print "Matched! Strings are palindromes.\n"; } else{ print "Sorry, the strings are not palindromes.\n"; } sub reverser{ my $temp = shift; my ($reverse, @temp, @temp2); @temp = split ('',$temp); foreach (@temp){ unshift(@temp2, $_); } $reverse = join('', @temp2); $temp eq $reverse?1:0; }