Aha!: My program requests user input.

If I replaced the <STDIN> with a typical user request, it works fine.

So the problem is getting it to play with STDIN. Now what??

EDIT: Here's a snippet of the code that's not working:

while(1) { print "\nEnter the day number you are interested in: "; chomp($sol_request=<STDIN>); #append 0 to the front if($day_request < 100 && $day_request !~/0[0-9][0-9]/) { $sol_request = "0".$day_request; } if(not -d "/somedir/$day_request/") { print "\nSol $day_request does not exist! Please try again +\n"; } else { last; } }
When I run the code with the pipe to more, the message "Enter day number" does not appear. Putting in a number works as usual, and the message does not print until after you hit <ENTER>. The number you enter also never appears on screen. The output correctly gets piped to more.

EDIT2: I guess I didn't quite understand what was going on with the more command. It captures everything going to STDOUT and more's it, right? I don't want that line going to STDOUT. I printed to STDERR instead and now that message shows. The user cannot see what he is typing, though. I could always print out what he typed to STDERR as well, but is a way to show the user what he's typing?


In reply to Re^2: How do I pipe the output of a Perl program to something else? by azredwing
in thread How do I pipe the output of a Perl program to something else? by azredwing

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.