in reply to Password with hashes

As you're dealing with passwords, I hope you've considered the security implications. If not, please do so.

A little more code than my %pword = (Rich => '', Broke => '',); would have been useful. I'm not sure why you'd consider reversing the hash. You haven't described what problem you're encountering using a username as a key. Here's a few code snippets that might prove helpful:

exists $pword{$username}
Returns TRUE if $username is a key in %pword, FALSE otherwise. See exists.
length $pword{$username}
Returns TRUE if a password has been set (i.e. not the original zero-length value of ''), FALSE otherwise. See length.
$pword{$username}
Returns the current password for $username.
$pword{$username} = $password
Sets a new password for $username.

If you're having fundamental problems with how to handle hashes, take a look at perldata.

-- Ken

Replies are listed 'Best First'.
Re^2: Password with hashes
by dsheroh (Monsignor) on Aug 10, 2012 at 08:26 UTC
    I'm not sure why you'd consider reversing the hash.
    Having seen people suggest similar things in the past, my assumption is that the reason for this is so that users can log in using only their password. Which is a thoroughly ill-conceived and insecure way of doing things. So, OP, if that was your intention, please don't do that.

      ++ While I don't recall seeing that usage myself, I completely agree with: ill-conceived, insecure and don't do it.

      -- Ken