# Build a hash lookup for things I want, defaulting to not there my %found; my @search; foreach my $item (@timearray) { my $id = "$NETID\|$month\/$date\/$year\|$item\|"; push @search, $id; $found{$id} = "||$item||"; } # Scan the file for them my $file = "/PHL/data1/PHL/tmp/ECL_STAT"; open(ECL_STAT, "< $file") or die "Cannot read $file: $!"; while () { chomp; if (/(([^\|]+\|){3})/ and exists $found{$1}) { $found{$1} = $_; } } # Build output array push @ECL, map $found{$_}, @search;