Hello! I'm new in perl but I need to write each element of an array into a file (appending). The array elements are the lines of another file starting with >.
I wrote the following:
open in, "rep_set_ass_tax.fna";
while ($line=<in>) {
if($line=~/>/) {
@vettore=split(/\s+/, $line);
open my $fh, ">>seq_id.txt" or die "Cannot open output.txt: $!";
foreach (@vettore);
print $_ . "\n";
close my $fh;
}
}
I have the following errors:
MacQIIME Mac-Pro-di-Francesca:cartella senza titolo $ perl taxa.pl
syntax error at taxa.pl line 6, near ");"
syntax error at taxa.pl line 8, near "$fh;"
Who can help me?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.