Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: BRUTEFORCE problem and a ?bug?

by mreece (Friar)
on Mar 19, 2007 at 16:43 UTC ( #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? | Other CB clients
    Other Users?
    Others examining the Monastery: (2)
    As of 2023-03-24 03:53 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Which type of climate do you prefer to live in?






      Results (60 votes). Check out past polls.

      Notices?