You also indicate that you would like to add users that are not on your system. It is for this reason that I suggest using a hash lookup (which is very fast) in this untested code.
Of course /user/defined/file should be set up like /etc/passwd if you care about the extra fields. Additionally, if you don't want to use /etc/passwd - I have shown the framework - you can have an "ok" %User and a "blacklist" %BadUser.#!/usr/bin/perl -w use strict; my %User; { local @ARGV; @ARGV = qw(/etc/passwd /usr/defined/file); while (<>) { chomp; my @field = split /:/; unless (exists $User{$field[0]}) { $User{$field[0]} = \@field; } else { print "WARNING: Duplicate found for $field[0]\n"; } } } my $testuser = "blah"; if (exists $User{$testuser}) { print "$testuser exists on system\n"; print "Field 4 for $testuser is $User{$testuser}->[3]\n"; }
Cheers - L~R
In reply to Re: User Existance?
by Limbic~Region
in thread User Existance?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |