Overall, it's pretty good. Good enough that I have a hard time believing your claim that this is your "first go at doing perl." :-)

If you don't want to use grinder's spew script (say you don't have /dev/urandom for instance) you might consider making this:

my @chars = ('a'..'z', 'A'..'Z', 0..9); my $plaintext_pass = do {{ local $_ = join "" => map {$chars [rand @chars]} 1..8; redo unless /[a-z]/ && /[A-Z]/ && /\d/; $_; }};
a little more readable like this:
my @chars = ('a'..'z', 'A'..'Z', 0 .. 9); my $plaintext_pass; PICK: { $plaintext_pass = ''; $plaintext_pass .= $chars[rand @chars] for 1..8; /[a-z]/ && /[A-Z]/ && /\d/ or redo PICK for $plaintext_pass; }
shrug

You might also want to reuse @chars in the list you use when picking the salt.

I agree with grinder's suggestion that using a module to send the mail is cleaner. I also agree with his suggestion that you re-scrub your variables.

Edit: Password picking code fixed to squash the bug that Arien pointed out in his reply. Arien++

-sauoq
"My two cents aren't worth a dime.";

In reply to Re: Desperate Coding Tidy-up by sauoq
in thread Desperate Coding Tidy-up by Anonymous Monk

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.