I think what you're doing is looking up a particular user
on a particular machine; and if that user doesn't exist
on that machine, then you're adding that user to that
machine list. Right? You should be using
push
to add the user to the array of users:
push @{ $machinearray{$machine} }, $pwline;
This will add $pwline to the end of the array.
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?
my %machines = (
machine1 => {
user1 => 'pwline1',
user2 => 'pwline2',
},
machine2 => {
user1 => 'pwline1',
user3 => 'pwline3',
},
);
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:
if (!exists $machines{$machine}{$uname}) {
## User doesn't exist. Add him/her.
$machines{$machine}{$uname} = $pwline;
}
Make sense?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.