in reply to Re^4: writing array element to a file
in thread writing array element to a file

It looks like you missed the square brackets around the array index in the print line.

print $out "vettore1\n"; # bad print $out "vettore[1]\n; # good

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

Replies are listed 'Best First'.
Re^6: writing array element to a file
by francesca1987 (Initiate) on Apr 25, 2013 at 14:38 UTC
    It wasn't the problem, brakets were there!
    my $infile = "rep_set_ass_tax.fna"; my $outfile = "seq_id.txt"; open my $in, '<', $infile or die "Can't read $infile; $!\n"; open my $out, '>>', $outfile or die "Can't read $outfile; $!\n"; while (my $line=<$in>) { if($line=~/^>/) { my @vettore=split(/\s+/, $line); print $out "$vettore[1]\n"; } }