in reply to Desperate Coding Tidy-up

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

Replies are listed 'Best First'.
Re: Re: Desperate Coding Tidy-up
by Arien (Pilgrim) on Aug 29, 2002 at 09:37 UTC
    my @chars = ('a'..'z', 'A'..'Z', 0 .. 9); my $plaintext_pass; PICK: { $plaintext_pass .= $chars[rand @chars] for 1..8; /[a-z]/ && /[A-Z]/ && /\d/ or redo PICK for $plaintext_pass; }

    Your password will be multiples of eight in length. (You append 8 chars every time you redo PICK.)

    — Arien