apache - First cgi script in perl and don't know what it does -
i new perl , looking cgi programs.
tried following perl monks , works. have no idea does.
1) end_here
? followed html
? :
print <<end_here; <html> <head> <title>my first cgi script</title> </head> <body bgcolor="#ffffcc"> <h1>this pretty lame web page</h1> <p>who ovid guy, anyway?</p> </body> </html> end_here
2) modified sample script adding:
my $query = new cgi; $p= $query->param('myparam');
i.e. new script is:
#!c:\perl\bin\perl.exe -wt use strict; use cgi; $query = new cgi; print $query->header( "text/html" ); $time = $query->param('fromdate'); print <<end_here; <html> <head> <title>my first cgi script $time</title> </head> <body bgcolor="#ffffcc"> <h1>this pretty lame web page</h1> <p>who ovid guy, anyway?</p> </body> </html> end_here # must have line after "end_here" or perl won't recognize # token
it stopped working. following error message:
undefined subroutine &main::param called @ c:/.../test2.cgi line 10.
how can parameters send browser if not way?
... <<end_here ... foo bar end_here
means
... "foo bar " ...
the choice of terminator you. can use bareword or string if add quotes. both following equivalent "foo\nbar\n"
:
<<meow foo bar meow <<"and lived happily ever after." foo bar , lived happily ever after.
the script posted has 2 problems, neither of them resulting in error specified.
perl can't find end of here-doc since no line contains solely
end_here
. have 1 containsend_here
whole bunch of leading spaces, that's not same thing. remove leading spaces.it allows arbitrary string placed in html. escape (using, say, html::entities's
encode_entities
)! consider happens if passes followingfromdate
parameter:<script>alert("owned")</script>
Comments
Post a Comment