szabgab has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to understand how Regexp::Common finds palindromes. I took out the code from the module that looks like this:
Would someone care to exmplain how it works? Are there other solutions not using (??{ code }) ?use re 'eval'; my $ch = '[a-zA-Z]'; my $palindrome; my $r = "(??{\$palindrome})"; $palindrome = qr/$ch|($ch)($r)?\1/; while (<>) { print if /^$palindrome$/; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: palindrome using regular expressions
by Hofmator (Curate) on Oct 10, 2006 at 11:28 UTC | |
by reneeb (Chaplain) on Oct 10, 2006 at 12:01 UTC | |
by Hofmator (Curate) on Oct 10, 2006 at 12:11 UTC | |
by strat (Canon) on Oct 11, 2006 at 07:58 UTC | |
Re: palindrome using regular expressions
by Anonymous Monk on Oct 10, 2006 at 11:56 UTC |
Back to
Seekers of Perl Wisdom