Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: writing array element to a file

by francesca1987 (Initiate)
on Apr 25, 2013 at 13:22 UTC ( [id://1030670]=note: print w/replies, xml ) Need Help??


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

Hi R! I modified the script as you suggested, while (my $line=<$in>) { if($line=~/^>/) { my @vettore=split(/\s+/, $line); print $out "$vettore1\n"; } } but the output file only contained 0, which is the number of the first line. What's I did wrong?

Replies are listed 'Best First'.
Re^5: writing array element to a file
by Random_Walk (Prior) on Apr 25, 2013 at 14:31 UTC

    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!
      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"; } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1030670]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-23 19:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found