Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Regex to compare (if) two strings (Uniquely - I will explain inside)

by CountZero (Bishop)
on Nov 24, 2012 at 19:08 UTC ( #1005415=note: print w/replies, xml ) Need Help??


in reply to Regex to compare (if) two strings (Uniquely - I will explain inside)

Using a regex:
use Modern::Perl; my $randword = join '', ('A'..'Z')[ map rand 26, 1..8 ]; say $randword; say "Make a word with the above characters"; my $word = <>; chomp $word; my $regex = (join '?', sort split '', $randword) . '?'; $word = join '', sort split '', $word; say "Comparing $word with $regex"; if ($word and $word =~ m/^$regex$/i){ say 'OK'; } else { say 'NOT OK'; }

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics
  • Comment on Re: Regex to compare (if) two strings (Uniquely - I will explain inside)
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005415]
help
Chatterbox?
[james28909]: hi, im james, and i am bat shit crazy. xD
[james28909]: crazy or genius....
[Eily]: hi bat shit crazy, I'm eily
[LanX]: hello James
[james28909]: lol
[james28909]: i honestly didnt thin kanyone was going to respond, or was even paying attention :l
[Eily]: well if you say something like that someone has to pay attention by law
[Eily]: Murphy's law to be precise

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2017-12-13 17:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (373 votes). Check out past polls.

    Notices?