#!/usr/bin/perl use strict; use warnings; open my $CUR, "<", "tdat_cur" or die "no tdat_cur"; open my $IPS, "<", "tdat_ips" or die "no tdat_ips"; my @cur = map { chomp ; $_ } <$CUR>; my %ips; foreach ( <$IPS> ) { # if there's a chance of $nam recurring you need to check for it. my ($nam, $ip) = split; $ips{$nam} = $ip; } foreach my $curious_about ( @cur ) { if( defined $ips{$curious_about} ) { print "$curious_about has IP addr $ips{$curious_about}\n"; } else { print "No IP addr information for $curious_about\n"; } }