http://qs321.pair.com?node_id=605521


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";