I started putting print statements in the methods of the package and they were printing on STDOUT (my console). Suddenly they stopped.
This is indeed odd. What did you change between "it works" and "it doesn't work"? STDOUT and STDERR are available everywhere unless the program specifically closes them or re-opens them to somewhere else - IMO both typically bad ideas - I'm sure there is some kind of exception, but I'd think long and hard before doing either. This is such an odd thing to do that I'd be surprised if that is what you have. However, anything is theoretically possible!

I don't think this is an issue here, but it might be. You should be aware of one fine point. STDOUT is by default buffered. STDERR is by default un-buffered. You can unbuffer STDOUT by adding the line: $|=1; to the top of main and each package. When you do that, any print to STDOUT will appear on the console immediately. The default behavior is to wait until some number of lines are ready for print and then they all appear at once. When the program exits normally, all buffers are flushed. However, I don't think that happens if you CTL-C or kill the process (not a normal program directed exit). If your program is hanging and you CTL-C it, you might not see previous STDOUT prints. Unbuffer STDOUT for debug. This slows down the max print rate, but has the advantage that Error messages (STDERR) and prints to STDOUT will appear in the correct time ordered sequence. Otherwise you might see an warning message and then 4-5 lines later see a STDOUT line that was actually related to the error message.

I must be missing a basic concept about the interaction between an imported module and STDOUT. So my question is: If I want to have a package print to STDOUT, is there something "special" that needs to be done?
Typically, the answer is "No".

In reply to Re: print statements in perl pakages seem to be masked from STDOUT by Marshall
in thread print statements in perl pakages seem to be masked from STDOUT by holandes777

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.