Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question About <STDIN>

Status
Not open for further replies.

quan

Programmer
Oct 3, 2001
58
US
Poking around with <STDIN>. Is this command only for command prompt type applications and not internet?

#! /usr/bin/perl
print (&quot;What is your name?&quot;);
$name = <STDIN>;
($name); #removes new line character
print (&quot;Hello, $name \n&quot;);


I am running this from my CGI bin on my internet server and it errors out. If I add the mime content line it prints but never prompts for input like the tutorial says it is supposed to. Any help is greatly appreciated. <i>Its okay to dream.....</i>
 
To make the page interactive you need to use a form. You could also use and applet or javascript. Putting your script on a webpage as a form using Perl would look like this, as a simple example:
Code:
use CGI;

my $q = new CGI;
print   $q->header,
        $q->start_html;

if ( $q->param() ) {

    print &quot;Hello, &quot;,$q->param('name'),&quot;<br>\n&quot;;

} else {

    print   $q->startform,
            &quot;What is your name? &quot;,
            $q->textfield('name'),
            $q->submit,
            $q->endform;

}
print   $q->end_html;

jaa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top