... open (ERRORFILE,"<", "Errors-email.txt") || die "File not found\n"; @error_array = ; ... foreach my $line(@error_array){ # # Some $line substitutions here... ... push(@sample_ids,$line); ...