#!/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"; }