Ok, what you put didn't work for me for some reason. I was getting some syntax errors. I played with it a little bit and this is what I got to work:
#!/usr/bin/perl -wT use strict; use CGI qw/:standard/; print "Content-type: text/html\n\n"; print header; my $date = localtime; my $body = param('body'); my $content = "body"; if ($body eq "yahoo") { $content = qq{<a href="http://www.yahoo.com/">Yahoo</a>\n}; } elsif ($body eq "date") { $content = $date; } print <<"EndOfHTML"; <html> <head><title>Some CGI test</title></head> <body> <h1>CGI Test</h1> <p>$content</p> </body> </html> EndOfHTML > --- Kyle Babich <[EMAIL PROTECTED]> wrote: > > I'm a beginner. The following is what I wrote: > > > > #!/usr/bin/perl > > print "Content-type:text/html\n\n"; > > > > @days = ("Sunday","Monday","Tuesday","Wednesday","Thursday", > > "Friday","Saturday"); > > @months = ("January","February","March","April","May","June", > > "July","August","September","October","November", > > "December"); > > > > ($sec,$min,$hr,$mday,$mon,$year,$wday,$yday,$isdst) = > > localtime(time); > > $year = $year + 1900; > > > > if ($body eq "yahoo") { > > > > print "<a href=\"http://www.yahoo.com/\">Yahoo</a>\n"; > > > > } elsif ($body eq "date") { > > > > print "$days[$wday] $mday $months[$mon] $year\n"; > > > > } > > Kyle, > > In addition to the other comments, you also have a typo in your header: > > print "Content-type:text/html\n\n"; > > There should be a space between the colon and the word "text". Most browsers will error correct > for this, but there are no guarantees. Here's one way to write this: > > #!/usr/bin/perl -wT > use strict; > use CGI qw/:standard/; > > print header; > > my $date = localtime; # because the left side is a scalar, localtime > # is in scalar context > # see perldoc -f localtime > my $body = param('body'); > > my $content = '"body" didn't match'; > > if ($body eq "yahoo") { > $content = qq{<a href="http://www.yahoo.com/">Yahoo</a>\n}; > } elsif ($body eq "date") { > $content = $date; > } > > print <<"END_HTML"; > <html> > <head><title>Some CGI test</title></head> > <body> > <h1>CGI Test</h1> > <p>$content</p> > </body> > </html> > END_HTML > > I realize that this is a lot of stuff to absorb, but rather than my try to pack it into an email, > check out my CGI course at http://www.easytstreet.com/~ovid/cgi_course/ > > Cheers, > Curtis "Ovid" Poe > > ===== > "Ovid" on http://www.perlmonks.org/ > Someone asked me how to count to 10 in Perl: > push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack (q|c|,$_);@a=split//; > shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A > > __________________________________________________ > Do You Yahoo!? > Yahoo! - Official partner of 2002 FIFA World Cup > http://fifaworldcup.yahoo.com > > -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]