File handle array
perl
Solution
That should simply be:
my @file_h;
for my $file (0..11) {
open($file_h[$file], ">", "seq.$file.fastq")
|| die "cannot open seq.$file.fastq: $!";
}
# then later load up $some_index and then print
print { $file_h[$some_index] } @record_r1[0..3], "\n";
Problem
I wanted to choose what data to put into which file depending on the index. However, I seem to be stuck with the following. I have created the files using an array of file handles: ``` my @file_h; my $file; foreach $file (0..11) { $file_h[$file]= new IT::File ">seq.$file.fastq"; } $file= index; print $file_h[$file] "$record_r1[0]$record_r1[1]$record_r1[2]$record_r1[3]\n"; ``` However, I get an error for some reason in the last line. Help anyone....?