Hello andyBio,

It looks as though your first while loop constructs filename strings and prints them out; then, immediately before the second while loop, you want to open the last constructed filename for writing. If this is what you are doing, there are three problems:

(1) As Laurent_R says, $temp is out of scope by the time you try to use it in the open statement. To fix this, you need to give it a wider scope:

... my $temp; # declare $temp before the loop while (...) { ... } close FASTQIN; my %count_seq; open my $fh, ... # $temp is still in scope ...

(2) The statement my $temp = print $head, $seq; doesn’t do what you want it to, because print returns a boolean value indicating whether the print operation was successful or not. You need something like this:

$temp = $head . $seq; print $temp;

(3) The first while loop’s condition may never be true, in which case $temp will never be initialized; so you should test for this possibility:

close FASTQIN; my %count_seq; if (defined $temp) { open my $fh, '<:encoding(UTF-8)', $temp or die "Cannot open $temp +$!"; while (<$fh>) { ... } }

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re^3: Manipulating tab delimited file by Athanasius
in thread Manipulating tab delimited file by andyBio

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.