open( FILE, "/PHL/data1/PHL/tmp/ECL_STAT.txt" ) or die "Couldn't open ECL_STAT.txt: $!"; my $found = 0; foreach $item(@timearray){ seek( FILE, 0, 0 ); $searchstring = "$NETID\|$month\/$date\/$year\|$item\|"; while( ) { if( /^$searchstring/ ) { push @ECL, $_; $found = 1; last; } } push @ECL, "||$item||" unless $found; } close( FILE ) or die "Couldn't close ECL_STAT.txt: $!";