On Friday, June 13, 2003, at 12:54 PM, [EMAIL PROTECTED] wrote:

password file format

user:passwd:uid:gid:gecos:homedir:shell


I need to be able to change any of the fields within each user record. While having the hash key remain the same user across many files.

I'm not sure I understand the question here, but the following should load a hash for you:


# Format:  user => [ passwd, uid, gid, gecos, homedir, shell ]
my %users;
foreach (grep !/^#/, split /\n/, `cat /etc/passwd`) {
        my($name, @details) = split /:/, $_;
        $users{$name} = [ @details ];
}

# sample printout
print "User: $_, Passwd: $users{$_}[0], ..., Shell: $users($_}[5]\n" foreach keys %users;


Hope that helps.

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to