On 6/23/07, Vahid Moghaddasi <[EMAIL PROTECTED]> wrote:

For each field (user) in the filter.in file, I will have to find the
user in passwd file, wouldn't I need to re-read the passwd file as
much as there are fields in filter.in file?

Probably not. For one solution, you might be able to use getpwnam to
get the information for each username individually, so you never need
to read from the password file at all.

   my($name, $passwd, $uid, $gid,
         $quota, $comment, $gcos, $dir, $shell, $expire)
       = getpwnam($username);

But maybe you need the actual password file.

I am not sure how much I can read into memory space without affecting
other programs but the entire FILTERfh could be a pretty large. Each
line could have up to 100 fields (users) and there could be 3 or 5
lines. How would I read them into memory? In an array?

300 to 500 usernames? If every username is meant to be unique, this
sounds like it's asking to be a hash. A hash with hundreds of
key-value pairs is easy for Perl to handle, so unless each value is
very large you shouldn't have memory issues.

Once you've built the hash, you can traverse the password file (or use
getpwent) and quickly identify the matching usernames from the hash.

Cheers!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to