19 users online (0 members and 19 guests)  


  Results 1 to 5 of 5

Related

  1. Perl/HTML issue    Forum: CGI Perl Forum
    Replies: 0
  2. A question about the html&perl    Forum: CGI Perl Forum
    Replies: 11
  3. How to email a HTML url in Perl    Forum: CGI Perl Forum
    Replies: 0
  4. Replies: 1
  5. Replies: 0
  1. #1
    rpuskarcik's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2006
    Location
    earth
    Posts
    3

    Serving up html using cgi-perl

    I would like to create a perl script which serves up an html page. Only one perameter needs to be passed to the script: something like http://www.website.com/page.htlm?1234

    When a person types the above in their browser, they get a webpage. By typing in a differant number at the end, they get almost the same webpage with some modifications, all performed by the perl script.

    Here is what I need help with:
    1. A simple example script to build apon, which accepts the parameter, and based apon it replaces some word or phrase, then serves up a simple html webpage.
    2. I need to know the details of how to set this up: where the script is physically located on the server (/cgi.bin)?
    3. What does page.html look like (or does it need to be shtml)
    4. Anything else I need to know...this is the first time i've attemted this.

    I am somewhat familiar with perl and have written some data extraction routines for use locally but have never written anything which runs on a server. So any information in this regard would certainly be usefull.

  2. #2
    netroact's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2006
    Posts
    19

    Re: Serving up html using cgi-perl

    I guess this is an old post, but maybe an answer would be helpful.
    You might wanna consider HTML::Template: http://search.cpan.org/~samtregar/HT....8/Template.pm
    1. This module allows you to add some parameters. 2. There are example perl CGI scripts on that page. 3. On most servers you can now install a perl script in any directory. But, it is better to keep them in the cgi-bin directory. You probably want to create a subdirectory in the cgi-bin, and put the script in there. 4. Of course, as always you need to set the permissions on your script to 755 after you upload it. 5. I would use an .html ending. Shtml is used for server side includes.
    This sounds like a real challenge for a first script. Have fun.

  3. #3
    sbryce's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2006
    Posts
    3

    Re: Serving up html using cgi-perl

    First, I doubt anyone is going to write this for you. Your specs are quite vague. If your specs were more specific, this would turn out to be a larger project than anyone would be willing to do for you in their spare time.

    If you take a stab at this and have trouble with it, someone here may be able to give you some pointers.

    Next, HTML::Template is a great module to use for what you want to do, but it only does part of it. The documentation includes example code for writing the HTML page, but not for grabbing the info that is passed into the CGI script. For that you want CGI.pm. Your web host should already have CGI.pm installed. If not, you are at the wrong host. The documentation for CGI.pm includes example code.

    If you need to install HML::Template.pm on your server, where you put it matters. If you donít put it in the right place, your script won't find it. Assuming your script is in the cgi-bin directory, create a cgi-bin/HTML/directory, and put HML::Template.pm there.

    The template file can be named anything you want and can be placed anywhere. Your server will never serve it up (hopefully), so normal requirements about where it is located and what it is named don't apply.

  4. #4
    rpuskarcik's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2006
    Location
    earth
    Posts
    3

    Re: Serving up html using cgi-perl

    Thanks for the input, I had all but given up, when I discovered how to do everything I needed using php. I still greatly appreciate the answers and I'll include your suggestions in my archive of useful information. Lastly, There may be someone out there, a newbe like me, that can make use of this... so thanks again.

  5. #5
    xmassey's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    100

    Re: Serving up html using cgi-perl

    As sbryce said HTML::Template would have been the perfect option for you...
    Using a URL like
    www.website.com/script.pl?name=value
    when you go to the address, the script could have picked up the value like this
    $value = param('name')
    You could then use HTML::Template to input value where needed in your separate html page i.e. index.htm
    This script would have taken 2 minutes to write, the long part would be designing your html page, which any web designer can do hehe
    Chris



Tags for this Thread