Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: searching problem

by Lotus1 (Curate)
on Jan 18, 2013 at 22:57 UTC ( #1014151=note: print w/replies, xml ) Need Help??


in reply to Re: searching problem
in thread searching problem

The way I understood the OP was print out the word which when in reverse matches any other word. Your solution does the opposite. For example instead of printing bar since 'rab' matches in arabic, it prints arabic. ymamaa was also printed since 'mamy' in reverse matches it. My point is that arabic in reverse doesn't match anything.

#!/usr/bin/perl use warnings; use strict; my @words = qw(mamy dady bal foo bar xrabbit ymamaa arabic); my $list = join ' ', @words; foreach( @words ) { my $rev = reverse $_; print "$_\n" if $list =~ /$rev/; } __END__ mamy bar

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1014151]
help
Chatterbox?
[choroba]: MCE
[karlgoethebier]: is about to reach nirvana tonight...
[Lady_Aleena]: It could have meant a "Miserably Cute Event" or "Man Crush Everyday". 8)
[Corion]: choroba: Re the one-shot thing, I also thought of bit vectors and/or indexes into one common array from the hashes, but that makes maintenance of all these indices a chorse
[Corion]: *core
[Corion]: ** chore
[Corion]: So I guess I will simply implement the linear scan first and wait with more fancy stuff until it becomes a problem
[karlgoethebier]: Lady_Aleena: ++ for "The Man Crusher Everyday"
[karlgoethebier]: this mad my day
[karlgoethebier]: no typo

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (13)
As of 2017-05-29 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?