note
jarich
<p>
Nope. <code>$_</code> contains a string. A key from <code>%users</code>; which is presumably a username. Your suggestion will therefore not work.
</p><p>
Had [PerlHeathen] written:
</p>
<code>
foreach(values %users) {
my %user=$_;
my $pw=getpwnam($user{uname});
my $homedir=$pw->dir;
}
</code>
<p>
(note the use of <b>values</b>) then $_ would be a reference to a hash and then your solution would make the code work.
</p>
<p>
For example:
</p>
<code>
foreach(values %users) {
my %user=%$_;
my $pw=getpwnam($user{uname});
my $homedir=$pw->dir;
}
</code>
<p>
It is likely that this is what PerlHeathen was trying to write in the first place.
</p>
<p>
jarich
</p>
516165
516173