I have some txt files with a huge list of lines like:
file_1.txt file_2.txt file_3.txt
XP_001703830.1 XP_001703820.1 XP_001703810.1
XP_001703836.1 XP_001703815.1 XP_001703805.1
XP_001703844.1 XP_001703834.1 XP_001703844.1
let's say that I have 10 or more files in a folder, and I want to read all of them and store the content in a array, I have used this code, but it just store one line of a file, and not all the lines !!
#!/usr/bin/perl -w
use strict;
my @files = glob("*.txt");
my @ID;
for my $file(@files) {
open IN, '<', $file or die "$!";
while (<IN>) {
my $fields = $_;
push @ID, $fields;
}
}
foreach (@ID){
print "$_\n";
}
close IN;
exit;
what I want is store all the lines in a array like:
XP_001703830.1
XP_001703836.1
XP_001703844.1
XP_001703820.1
XP_001703815.1
XP_001703834.1
XP_001703810.1
XP_001703805.1
XP_001703844.1
Thanks So Much !!!
close IN;should be underforloop where you are opening a txt file.@ID?cat?