Fellow monks, I know you are all rolling your eyes and going for the -- button. But hold on. I know this is Chapter 1 stuff in any Perl book, and I should have figured this out years ago. But for some reason I have never been able to make it work. Am I'm tired of writing an HTML form every time I need some simple input.

I tried examples from Learning Perl and Programming Perl (The Cookbook uses Term::Readkey for all its examples), those found from Google searches and PM's very own Super Search--and there are hundreds of them.

When I save this insanely simple script to my server and access it from a browser, it prints the prompt and then nothing. I thought I'd have a cursor, I would type something, see what I was typing, and then hit RETURN and the results would be printed to screen.

What am I not getting?
#!/usr/bin/perl print "Content-type: text/plain\n\n"; use CGI::Carp qw(fatalsToBrowser); use strict; use warnings; # $| = 1; print "What is your name? "; my $name= <STDIN>; chomp $name; print $name,"\n";
TIA!

—Brad
"A little yeast leavens the whole dough."

In reply to Really, how do I get input from the keyboard. by bradcathey

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.