jdporter and the others have showed you what was giving unexpected results on every run. There is one more error that will occasionally give you problems, perhaps without your ever knowing it.

You have a 'race condition' on your savedpasswords.txt file. That means that two instances (call tham A and B) of your script running at the same time can give you a corrupt save file. If the sequence

  1. A opens to read,
  2. B opens to read,
  3. B opens to write,
  4. A opens to write.
occurs, B fails to check its generated password against A's.

By opening to append rather than truncate when you write, you avoided the much more serious error of B's result being not recorded after the above sequence. In either case the probability of error is small, but it is a structural problem that can do you serious injury in other circumstances. The worst that can happen here is that two users have the same hashed passwd, with mischief available to the first one to notice.

To fix the problem, open the file only once, in '+>>' mode, and do not close it again until you have written the new password.

I'd like to second virtualsue's more general advice, it is the best way I know to get comfortable with a language.

After Compline,
Zaxo


In reply to Re: Variable still not holding contents by Zaxo
in thread Variable still not holding contents by sulfericacid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.