in reply to writing array element to a file
At a first glance, it seems you need a pair of braces around the print statement. And the file handle in the print statement.
while ($line=<in>) { if($line=~/>/) { @vettore=split(/\s+/, $line); open my $fh, ">>seq_id.txt" or die "Cannot open output +.txt: $!"; foreach (@vettore) { # { was missing here, removed ; print $fh $_ . "\n"; # file handle was missing } # } was missing here close $fh; # removed my } }
UPDATE: The regex for > at the beginning of line is /^>/. The name of the file you are trying to open for writing is inconsistent with the error message.
|
|---|