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

Re: BRUTEFORCE problem and a ?bug?

by mreece (Friar)
on Mar 19, 2007 at 16:43 UTC ( [id://605521]=note: print w/replies, xml ) Need Help??


in reply to BRUTEFORCE problem and a ?bug?

please use <code>..</code> tags so your code is easier to read and copy/paste.

you have a couple of problems:

  • zero, you are missing "w" from your alphabet.
  • one, you should chomp $hladane immediately after reading it rather than at the end of the while loop.
  • two, your assignments $alphabet[$nummer] = $slovo are backwards, and you are slowly undefing each element of @alphabet.

    consider:

    use warnings; use strict; my @alphabet = ( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" ); my $nummer = 0; my $slovo; print "Tell me your pass (only small alphabet only ONE a-z)"; my $hladane = <STDIN>; chomp $hladane; print "$alphabet[$nummer] \n"; $slovo = $alphabet[$nummer]; while ($slovo ne $hladane) { $nummer = $nummer + 1; print "$alphabet[$nummer]\n"; $slovo = $alphabet[$nummer]; } print "GOTCHA $hladane !!! \n";
  • Log In?
    Username:
    Password:

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

    How do I use this?Last hourOther CB clients
    Other Users?
    Others browsing the Monastery: (8)
    As of 2024-03-28 23:59 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found