in reply to Re: While loops with if
in thread While loops with if

Please take the advice of other posters and fix your indentation. It will make your life much easier.

The easiest answer as to why your password doesn't match is because you never read anything from the password file. Inside your loop, $usedpw is still set to 'logfile.txt'. I suspect you want something more like this:

open USEDPW, 'logfile.txt' or die "Cannot read logfile: $!\"; my $seen; while (<USEDPW>) { chomp; $seen++, last if $pw eq $_; } print "Your unique password is '$pw'\n" unless $seen;

I'm not sure that's what you really want, though... and it'd be more efficient to use a DBM file.