in reply to Passing Parameters Help!

moritz and cool are both right. It is very difficult from your explanation to work out what behaviour you expect to have from your code. Using the modules moritz has listed would really help to tidy things up and make maintenance and fault finding more easy - as well as helping the monks to help you.

Looking at you code, I guess you want to print the values of "insert", "display" and "confir" which are passed by your HTML template. Once this is done you want to open a file called "table.html" which is in the same directory as the script (you have not listed the contents of this file anywhere...). You then want to look at each line in this file and replace "<-- MESS// -->" with "OK your message has been received!" if the value of insert passed from your HTML form is equal to "insert"; otherwise you will replace "<-- MESS// -->" with "".

I have assumed that "table.html" is your HTML template code. When I run your script from the command line I get:
> perl mess.pl insert=insert display=test2 confir=test3 Content-Type: text/html; charset=ISO-8859-1 <br><b>I must to print these values here once the buttons on the form +has been clicked:</b><br>***INSERT=insert******DISPLAY=test2******CON +FIR=test3######<br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric +t//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Test</title> </head> <body> Test<br> <form name="upf" method="post"> <input type="hidden" name="update" value="update"> <input type="submit" name="upf" value="Cancel" onClick="docum +ent.upf.action='test.pl';"> <br><br> <input type="submit" name="upf" value="Insert" onClick="docum +ent.upf.action='test.pl?insert=insert';"> <br><br> <input type="submit" name="upf" value="Confirm" onClick="docu +ment.upf.action='test.pl?confir=confir';"> </form> OK your message has been received! </body> </html>
This looks like what you might expect. The html is badly formed though since the DOCTYPE declaration comes after you have already outputted some data... browsers will probably interpret it but you may want to tidy this up before going live with it.

Replies are listed 'Best First'.
Re^2: Passing Parameters Help!
by Marmota_11 (Initiate) on Jul 10, 2007 at 18:49 UTC
    Yes, that's what I am expecting, just can't see where the problem is, and I did the same running like you did and it works, but doing from the browser I can't get the value of "insert" or from any of the parameters into the perl.
    Did you try running it from the browser?
      Okay. I've spent a while looking at this and now I'm going cross-eyed. I've got it working on my webserver after a bit of manipulation.

      I've modified the table.html file to the following:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3 +.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Test</title> </head> <body> <p>Test</p> <form method="get" action="/cgi-bin/test.pl"> <input type="hidden" name="update" value="Update"/> <input type="submit" name="cancel" value="Cancel"/> <input type="submit" name="insert" value="Insert"/> <input type="submit" name="confir" value="Confirm"/> </form> <!-- MESS// --> </body> </html>
      ... and changed the line:
      if($insert eq "insert"){
      to:
      if($insert eq "Insert"){
      The other change I made was to put the full path name into the $out_file line, like so:
      $out_file = "/opt/csw/apache/htdocs/table.html"; open(OUTPUT, "$out_file") || print "L40 - There is no file here, I'll +run away now!";
      My guess is that when you create the filename $out_file something is going wrong (perhaps you are pointing at the wrong directory, maybe the perl script and the html page are not in the same place), you then try to open the file which doesn't exist and so get the "L40" error message.

      You've been given a number of good options for correctly finding the path of the file and a number of recommendations for modules to make your life easier (the template modules for example) - it might be time to look at those more closely.