in reply to Hash table of arrays
This will add $pwline to the end of the array.push @{ $machinearray{$machine} }, $pwline;
You may want to think about alternate data structures, though, if you're going to be looking up a lot of users. Something like this, perhaps?
This way you can quickly look up a particular user on a particular machine, and you also have access to the password lines. Then you could do:my %machines = ( machine1 => { user1 => 'pwline1', user2 => 'pwline2', }, machine2 => { user1 => 'pwline1', user3 => 'pwline3', }, );
Make sense?if (!exists $machines{$machine}{$uname}) { ## User doesn't exist. Add him/her. $machines{$machine}{$uname} = $pwline; }
|
|---|