You're right, the (corrected) code won't find palindromes. It wasn't intended to. It was the first step in finding a palindrome candidate.
OK, fair enough. So what did you want it to do? Did you just want to check for repeated characters at the proper end of word boundaries?
[Insert "Lightbulb Over Head" graphic here ]
You just want a filter to grab candidates, then strip whitespace, then test for palindrome-ness.
I think you'd do us a favor by coming up with an appropriate regex with ??{code}, something near:
/(\b
(([a-z]) # at least one char
?{local @suffix; push @suffix, $^N}) # build up suffix
(([a-z)
?{local @suffix; push @suffix, $^N}
| \S+)+
[a-z]? # possible odd char
(([a-z])
(?{if ($^N eq $suffix[-1]) {pop @suffix}})
| \S+)+)
(([a-z])
(?{if ($^N eq $suffix[-1]) {pop @suffix}})
\b)
/x
Though I don't think that works, and it's untested. (Hey, I have to leave something up to you.) Besides, there's a lot left out of the perlre with ?{code} and ??{code}, so please come back and tell us what it should say :)
-QM
--
Quantum Mechanics: The dreams stuff is made of
| [reply] [Watch: Dir/Any] [d/l] [select] |