"The scripts are pretty big ..."

That makes no sense in response to an implicit suggestion to read: The SSCCE: Short, Self-Contained, Correct (Compilable) Example.

From your OP:

"Unable to flush stdout: Invalid argument?"

Find out what generates that message and track back from there.

You might also consider modifying that code such that it produces a more useful message. Something like:

"open(LOG, ">>/Logs/Report.log") ..."

Avoid using global package variables: that leads to action-at-a-distance and bugs that are hard to track down. Instead, use lexical variables in the smallest scope possible.

Use meaningful names. Using common, globally scoped, package variables (e.g. FILE, LOG, IN, OUT), just exacerbates the problem and makes your debugging task all the more difficult.

Read the open documentation, then rewrite that code more like this:

open my $report_log_fh, '>>', $logfilename ...

Not checking for I/O errors is also a problem. Either write your own; something like:

... or die "Can't open '$logfilename' for appending: $!";

Or save yourself all that effort and let Perl do it for you with the autodie pragma.

"carpout('LOG');"

Read the CGI::Carp documentation:

"The carpout() function requires one argument, a reference to an open filehandle for writing errors."

Your argument, 'LOG', is a literal string.

Does your script start with these two lines?

use strict; use warnings;

If not, add them. They may well highlight all sorts of problems you weren't aware of. Like autodie, strict and warnings are two more examples of Perl doing the work for you, if you just ask.

Finally, kindly read "How do I post a question effectively?" and follow the instructions therein. We're happy to help but we're not psychic: if you provide the appropriate information, you'll usually get a quick response, that actually answers your question, rather than guesswork and requests for more information.

— Ken


In reply to Re^3: Unable to flush stdout: Invalid argument by kcott
in thread Unable to flush stdout: Invalid argument by bakiperl

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.