Вы можете использовать AnyData :: Format :: Password :
#!/usr/bin/perl
use strict; use warnings;
use AnyData;
my $passwd = adTie(Passwd => 'passwd' );
my $shadow = adTie(Passwd => 'shadow' );
for my $user (keys %$shadow) {
if ( $user->{fullname} and $user->{fullname} eq '999999' ) {
print $passwd->{$user->{username}}{fullname}, "\n";
}
}
Выход:
...
Privilege-separated SSH
RPC Service User
Anonymous NFS User
HAL daemon
Или:
for my $user (keys %$shadow) {
if ( $user->{fullname} and $user->{fullname} eq '999999' ) {
my @values = map { defined $_ ? $_ : '' }
@{ $passwd->{$user->{username}} }{@fields};
print join(':', @values), "\n";
}
}