Hi Perl Monks!

I've finished writing a script, and now I want for it to print all messages both to screen and to a (log) file. So a little googling pointed me to this File::Tee module. Installed it (locally as I'm not root) and ran just a basic example.
But I have a problem making it work with STDIN. Here is a little code that doesn't work right, or at least it doesn't work as I thought it should.
#!/usr/bin/perl -w use lib '/path/to/local/lib/'; use File::Tee qw(tee); ################ ## No bug yet ## ################ #Print Starting Info print ("=============================\n"); print (" Just a simple bug example \n"); print ("=============================\n\n"); # Get user input print ("Enter anything: "); $CODE = <>; chomp ($CODE); print ("You used $CODE!\n=============================\n\n"); ################ ## Here it is ## ################ # Start with Tee tee(STDOUT, '>', 'logfile.txt'); #Print Starting Info print ("=============================\n"); print (" Just a simple bug example \n"); print ("=============================\n\n"); # Get user input print ("Enter anything: "); $CODE2 = <>; chomp ($CODE2); print ("You used $CODE2!\n=============================\n\n");
It works right until it comes to the tee(...) part. Then it just waits for my blind input before printing the input message... Here is the output
============================= Just a simple bug example ============================= Enter anything: PerlMonks You used PerlMonks! ============================= ============================= Just a simple bug example ============================= TeeTestPM perl/teetest> Enter anything: You used TeeTestPM! =============================
Anyone could help out?

Thanks a bunch!
Cheers!

In reply to Tee Module by Ballistic

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.