Hello All,
I have this problem that I can't seem to see what is going on. The
following code gives me the following output...
#!/usr/bin/perl -w
use Data::Dumper;
my $file = '/etc/passwd';
my $procrc = '.procmailrc';
sub view_users{
open( PASSWD, $file) or die "$file: $!\n";
flock(PASSWD, 2) or die "Can't lock $file exclusively: $!";
my (@users, %popusers);
# Process the password file
while (<PASSWD>) {
my ($username, $groupid, $fullname) = (split/:/)[0, 3, 4];
# Skip disabled accounts
next if $username =~ /^\*/;
# Only keep those users in group 45
if ( $groupid == 45 ) {
push @users, $username, $fullname;
}
}
# Test each account for the existance of the ..procmailrc file
for (1 .. (scalar @users) / 2) {
my ($username, $fullname) = @users[$_-1, $_];
# Perform the check
my $exists = (-e "/home/$username/$procrc") ? ('YES') : ('NO');
# Place the information into the hash we return
$popusers{$username}{$fullname} = $exists;
}
close PASSWD or die "$file: $!\n";
return %popusers;
}
view_users();
print Data::Dumper -> Dump( [\%popusers], ['*popusers']);
___END OF PERL CODE___
This prints....
%popusers = ();
There are no compilation errors and I can't seem to see anything
obviously wrong with the code.
Any ideas?
Regards,
Dan
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]