chinamox has asked for the wisdom of the Perl Monks concerning the following question:
Hello again all,
I am working of a project that has me looking for palindromes. So far I have sussed out this much:
use strict; use warnings; my $palindrome = 'anna'; my $test = reverse $palindrome; print "$palindrome is a palindrome. \n" if $test = $palindrome;
I have two major challenges left.
First, as per Chargrill's point below, I think I need to delete all the white space to make sure I don't get 'A Danish custard--drat such sin, Ada's back at me.
Second, I only want to find palindromes with the lengnth of four characters or more , so 'bob' should not be printed.
Third, I need it to ignore capital letters, so 'Anna' should be printed. Is there a way to slap an 'i' on the back of this script or must I resort to a regex? Could this be combined with getting rid of white spaces?
Thanks for any pointers and your time!
-mox
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Improving a palindrome script...
by chargrill (Parson) on Oct 24, 2006 at 18:48 UTC | |
by liverpole (Monsignor) on Oct 24, 2006 at 19:25 UTC | |
by chinamox (Scribe) on Oct 24, 2006 at 23:51 UTC | |
by liverpole (Monsignor) on Oct 25, 2006 at 10:35 UTC | |
|
Re: Improving a palindrome script...
by ikegami (Patriarch) on Oct 24, 2006 at 18:56 UTC | |
|
Re: Improving a palindrome script...
by liverpole (Monsignor) on Oct 24, 2006 at 18:57 UTC | |
by chinamox (Scribe) on Oct 24, 2006 at 19:02 UTC | |
by ikegami (Patriarch) on Oct 24, 2006 at 19:05 UTC | |
|
Re: Improving a palindrome script...
by skx (Parson) on Oct 24, 2006 at 21:41 UTC | |
|
Re: Improving a palindrome script...
by driver8 (Scribe) on Oct 25, 2006 at 02:09 UTC | |
by Anonymous Monk on Oct 25, 2006 at 11:19 UTC |