That is strange. Which version of perl are you using and what platform? If you posted the output from perl -V that would tell us the full story.

Not that this ought to make a difference, if append mode was failing in some build or on some platform, I would have expected it to have been noticed already, but it might rings some bells with someone, somewhere and provide a clue that might help.

With respect to return code checking. The usual idiom is

open OUT, '>>', 'Results.txt' or die "Open for append to Results.txt failed. rc: $!";

The two main differences here are that the error message will be output to STDERR rather than STDOUT which can be useful for seperating error output from 'normal' ouput via command line redirection. And the inclusion of the perl special variable $! which will contain an error message indicating why the operation failed. Good info to have when trying to solve such failures.

There's nothing wrong with the way you're doing it, but I'd advise the incusion of $! to your output.

None of that solves your problem though. I can't think of a situation where opening a file for append would succeed in opening it, but blow away the contents in the process. Maybe someone else has seen this?

If it really in doing this, it might be worth trying the 2-arg form of open

open OUT, '>> Results.txt' or die ...;

If your build of perl really does containing a bug that is affecting append mode, there is a slight chance that using a slightly different code path might change something.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.


In reply to Re: Re: Re: Sanity Check: Debugging Help Needed! by BrowserUk
in thread Sanity Check: Debugging Help Needed! by Anonymous Monk

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.