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.

  1. perl can't find end of here-doc since no line contains solely end_here. have 1 contains end_here whole bunch of leading spaces, that's not same thing. remove leading spaces.

  2. it allows arbitrary string placed in html. escape (using, say, html::entities's encode_entities)! consider happens if passes following fromdate parameter:

    <script>alert("owned")</script> 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -