Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: JAPH palindrome.

by JavaFan (Canon)
on Sep 25, 2010 at 16:57 UTC ( [id://861976]=note: print w/replies, xml ) Need Help??


in reply to Re: JAPH palindrome.
in thread JAPH palindrome.

if ($half1 =~ $flip)
Really? It doesn't matter if $flip contain regexp special characters, or if $flip matches $half1 partially?

I'm also wondering why you bother splitting the text into two. Wouldn't something like:

use Test::More; use autodie; open my $fh, "<", $file; undef $/; $text = <$fh>; chomp $text; $text =~ s/\s+//g if $lax_in_whitespace; ok $text eq reverse $text, "palindrome"; done_testing;
be enough?

Replies are listed 'Best First'.
Re^3: JAPH palindrome.
by jffry (Hermit) on Sep 26, 2010 at 07:09 UTC

    Regarding splitting and flipping it, I guess I was too hung up on the mental steps I was taking to create a palindrome in the first place. I must have coded some analog of what my brain was doing. Twelve hours later, it looks very foolish.

    The =~ vs eq bug is just an outright screw up. I have no excuse for that one.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://861976]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-19 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found