Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Array issue

by pelagic (Priest)
on Jan 28, 2004 at 20:31 UTC ( [id://324775] : note . print w/replies, xml ) Need Help??

in reply to Array issue

I'll try to explain what each of your stmts does:

 my ($mkt,$pass) = split;
assign first word of line (user or whatever that is) to $mkt
and Password (second word of line) to $pass

$passwds{$mkt} = $pass;
assign Password to hash/key %passwds/$mkt
assign User to hash/key %passwds/$pass
At the end you got a hash with every User _AND_ every Password as key. The values contain vice versa the Passwords and the Users.
Now it's impossible to have just a list of the Passwords because you cannot distict them anymore.

just do:
$passwds{$mkt} = $pass; in your loop and then you can get all Users or all Passwords like that:
@listOfPass = (values %passwds); @listOfUsers = (keys %passwds);

close if stmt with } before accessing the whole list ...