I read a post that was previously asked in this forum on how to write over text using the \r metacharacter. It seems to be behaving poorly in one case I am working on.

I am using opendir(DIR, "$directory")
to open a directory of directories, and then opendir(SUBDIR, "$directory/$subdir") to read through the subdirectories. Each subdirectory has some number of files I am interested in. (in this case, they are dna sequences, and I want to know their lengths).

I can get the subdirectory name, the number of files checked in that directory, the total number checked across all subdirectories, and some other data, just fine. The problem comes in displaying it in a dynamic fashion.
If $library is the subdirectory name, $library_sequence_count is the number of sequences processed in $library, and $project_sequence_count is the total number of sequences read, then I use the statement:
print STDERR "\t\t\t\t\r\t$library\t$library_sequence_count\t$project_sequence_count\r";
to display this as it goes. This works fine - until I run into libraries with large numbers (say, 10,000+) of sequences.

When a large library passes by, the last digit of its count remains in the second field as the new libraries come and start writing. (this is why I tried the large string of tabs followed by a \r before actually writing). I can't seem to figure out why I can't get rid of this extra digit that doesn't actually belong to $library_sequence_count.

Any thoughts would be most appreciated...


In reply to Oddity with \r printing by MrMadScience

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.