in reply to Re: More Power to your Regex
in thread More Power to your Regex

Well, I just typed up something that you might find interesting, its worth a look at least:

print "Type a word or phrase: "; $line = <STDIN>; $line =~ s/\W//g; # removes space and nonalphanumerics $line =~ tr/A-Z/a-z/; # converts to lowercase. @letters = split //, $line; $reverse = join "", reverse @letters; # gets the letter and reverse it if(@letters == 1){ print "One letter palindrome, trivial!\n"; } elsif($reverse eq $line){ print "This is a palindrome.\n"; } else{ print "Not a palindrome.\n"; }


If you have any thoughts about this, be sure to /msg me. However, its much cooler to have a single regex do it than having all those lines of code. Peace... BlackFlag.