Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Regex Matching

by ec1987 (Initiate)
on Dec 05, 2012 at 20:22 UTC ( #1007388=perlquestion: print w/ replies, xml ) Need Help??
ec1987 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
I'm in the process of writing a script that generates 8 Random Characters and the user has to make words from these characters. Each character can only be used once. For example, if the random sequence is FOTBIEIW and the user enters FOOT it will show an error message "No match". If the sequence was FOTBOIEW then FOOT would be acceptable.
To generate the random letters im using:
my @letter=('A'..'Z'); @rand=''; foreach(0..7){ $rand.=$letter[rand(@letter)]; Then I get the user to enter a word split it into an array. This is where I get stuck. for($count=0; $count<= ($wordLength - 1); $count++){ if($wordArray[$count] =~ /[$rand]/o{

Original content restored by GrandFather

Comment on Regex Matching
Download Code
Re: Regex Matching
by CountZero (Bishop) on Dec 05, 2012 at 20:37 UTC
    Homework? I remember someone else posting exactly the same question some time ago.

    Use Super Search to find a lot of good suggestions.

    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
Re: Regex Matching
by AnomalousMonk (Monsignor) on Dec 05, 2012 at 20:39 UTC
Re: Regex Matching
by Kenosis (Priest) on Dec 05, 2012 at 21:42 UTC

    It appears that the 'chalkboard' was just erased...

      but the thought lives on (edited to correct some rendering deficiencies)...

      "Hi Monks,
      "I'm in the process of writing a script that generates 8 Random Characters and the user has to make words from these characters. Each character can only be used once. For example, if the random sequence is FOTBIEIW and the user enters FOOT it will show an error message "No match". If the sequence was FOTBOIEW then FOOT would be acceptable.
      "To generate the random letters im using:"

      my @letter=('A'..'Z'); @rand=''; foreach(0..7){ $rand.=$letter[rand(@letter)];
      </code>

      "Then I get the user to enter a word split it into an array.

      "This is where I get stuck."

      for($count=0; $count<= ($wordLength - 1); $count++){ if($wordArray[$count] =~ /[$rand]/o{

      Courtesy of Corion's good works (+ +), we have our own, local 'sorta go a ways back' machine.

        "Once the chalkboard has been erased, it can't be unerased..."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1007388]
Approved by 2teez
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2014-07-26 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls