Loading ...
Sorry, an error occurred while loading the content.

View Source Code?????

Expand Messages
  • thehl1970
    OK, I am writing my first PERL script. While a highly-seasoned software developer, I m new to PERL and somewhat new to CGI. (I ve written CGI s in COBOL,
    Message 1 of 14 , Jul 3, 2005
    • 0 Attachment
      OK, I am writing my first PERL script. While a highly-seasoned
      software developer, I'm new to PERL and somewhat new to CGI. (I've
      written CGI's in COBOL, believe it or not!)

      I am testing using Apache 2.0 and firefox as my web browser. I
      downloaded the guestbook.cgi app to clone from. I have written and
      tested my script and was happy with it. Now I run it from my web
      client and what I see on my screen is the HTML source. How can this be?

      I then immediately attempted running guestbook.cgi and it works fine.
      Go back to mine, and I get source code. I thought maybe something was
      funny in the HTML, so I saved it off to an html file and opened it and
      it worked fine. Any ideas as to where to go from here?

      Here is my script. It's not finished so you'll see some strange code
      that doesn't do anything.

      #! /usr/bin/perl
      ######################################################################
      # rex_config
      # Copyright 2005 Heavyweight Software
      ######################################################################
      # Function : performs configuration for the rex conversion utility
      ######################################################################
      ##################### license & copyright header #####################
      # #
      # Copyright (c) 2005 by Heavyweight Software
      # #
      # This program is distributed as part of the rex package. All
      # reserved.
      ################### end license & copyright header ###################
      ######################################################################
      # Global Variables:
      ######################################################################
      require 'cgi-lib.pl';

      print 'Start';

      # Messages for later use
      %UsersMessages = ("UN_IDENT", "An un-identified error occured in:",
      "Back" , "Back");
      # Error codes
      $ERR_UN_IDENT=1024;

      @date= localtime(time);
      @Months =
      ('January','February','March','April','May','June','July','August','September','October','November','December');
      $date[5] += 1900;
      $Time = "$date[3] $Months[$date[4]] $date[5]";

      ######################################################################
      # This is main processing routine
      ######################################################################

      $Ret = &ReadParse(*input);
      if ($Ret==0)
      {
      $Page = 0;
      } elsif ($Ret>0)
      {
      $Page = $input{'Page'};
      } else
      {
      &Error($UsersMessages{'UN_IDENT'},ERR_UN_IDENT);
      exit;
      }

      print &StoreValues($Page);

      $Page++;

      &PrintConfigPage($Page);

      exit;
      ######################################################################
      # End of main routine
      ######################################################################

      ######################################################################
      # Sub-routines here
      ######################################################################

      # Generates the back button for error pages
      sub Back
      {
      return <<EOF;
      <FORM>
      <BR>
      <BR>
      <BR>
      <TABLE WIDTH="100%">
      <TR>
      <TD WIDTH="75%" ALIGN="Right">
      <INPUT TYPE="image" BORDER=0 ONCLICK="history.go(-1);"
      NAME="goback" SRC="images/next.png"/>
      </TD>
      <TD>
       
      </TD>
      </TR>
      </TABLE>
      </FORM>
      EOF
      }

      # error routine generates an error page
      sub Error
      {
      my($ErrorText, $Exit) = @_;
      print &HTMLHeader($ErrorText);
      print &Back($GuestbookURL);
      print &HTMLEnd;
      if($Exit) { exit; }
      }

      # prints the Html footer
      sub HtmlEnd
      {
      return <<EOF;

      <BR> <BR>

      <CENTER><P class="app_name">
      RE Transform Converter--Configuration Utility
      </P></CENTER>
      <CENTER><BR><BR>
      <EM>© Copyright 2005 <A
      HREF="http://www.HeavyweightSoftware.com/Rex">Heavyweight
      Software</A>. All rights reserved.</EM>
      </CENTER>
      </BODY></HTML>
      EOF
      }

      # prints the Html Header
      sub HtmlHeader
      {
      my($Title) = @_;
      $HeadTitle = $Title;
      $HeadTitle =~ s/\<\w\w*\>/ /gi;
      return <<EOF;
      Content-type: text/html

      <HTML>
      <HEAD>
      <TITLE>$HeadTitle</TITLE>
      <META HTTP-EQUIV="content-type" CONTENT="text/html;charset=iso-8859-1"/>
      <META NAME="ROBOTS" CONTENT="NOINDEX, FOLLOW"/>
      <META NAME="description" CONTENT="none"/>
      <META NAME="keywords" CONTENT="none"/>
      <META NAME="Author" CONTENT="Heavyweight
      Software--www.HeavyweightSoftware.com"/>
      <META NAME="GENERATOR" CONTENT="CGI Script by Heavyweight Software"/>

      <LINK REL="stylesheet" HREF="heavyweight.css" TYPE="text/css">
      </HEAD>
      <BODY BGCOLOR="#FFFFFF">
      <CENTER><H1>$HeadTitle</H1></CENTER>
      EOF
      }

      # Generates the approriate configuration page
      sub PrintConfigPage
      {
      my($PageNo) = @_;
      print &HtmlHeader('Rex Configuration--Page '.$PageNo);

      print <<EOF;
      <FORM ACTION="/cgi-bin/rex_config.cgi" MEHTOD="post"
      NAME="Configure$PageNo">
      <INPUT TYPE="hidden" NAME="Page" VALUE="$PageNo"/> <BR>

      <CENTER>
      <H2>Choose MLS type</H2>
      <SELECT NAME="IdxType" WIDTH="100%">
      <OPTION VALUE="Voyager2">FNIS Voyager 2</OPTION>
      <OPTION VALUE="BG">The Bowling Green one</OPTION>
      </SELECT>
      </CENTER>

      <BR>
      <BR>
      <BR>
      <TABLE WIDTH="100%">
      <TR>
      <TD WIDTH="75%" ALIGN="Right">
      <INPUT TYPE="image" BORDER=0 NAME="doit"
      SRC="images/next.png"/>
      </TD>
      <TD>
       
      </TD>
      </TR>
      </TABLE>

      </FORM>

      EOF

      print &HtmlEnd;
      }

      # Stores values to the configuration file
      sub StoreValues
      {
      my($PageNo) = @_;
      }
    • Charles K. Clarkson
      ... This is REALLY the wrong script to be using as a model. Check Google for the NMS perl scripts. NMS should have a guestbook script which is written using
      Message 2 of 14 , Jul 3, 2005
      • 0 Attachment
        thehl1970 <> wrote:

        : OK, I am writing my first PERL script. While a highly-seasoned
        : software developer, I'm new to PERL and somewhat new to CGI. (I've
        : written CGI's in COBOL, believe it or not!)
        :
        : I am testing using Apache 2.0 and firefox as my web browser. I
        : downloaded the guestbook.cgi app to clone from. I have written and
        : tested my script and was happy with it. Now I run it from my web
        : client and what I see on my screen is the HTML source. How can this
        : be?

        This is REALLY the wrong script to be using as a model. Check
        Google for the NMS perl scripts. NMS should have a guestbook script
        which is written using more modern perl programming techniques. I
        don't even want to look at this stuff. Blech!

        HTH,

        Charles K. Clarkson
        --
        Mobile Homes Specialist
        254 968-8328
      • thehl1970
        I would appreciate any HELPFUL advice you may have. If there are things in my script you would like to suggest improvement on, I will be more than happy to
        Message 3 of 14 , Jul 3, 2005
        • 0 Attachment
          I would appreciate any HELPFUL advice you may have. If there are
          things in my script you would like to suggest improvement on, I will
          be more than happy to listen to them.

          Thanks.

          --- In perl-beginner@yahoogroups.com, "Charles K. Clarkson"
          <cclarkson@h...> wrote:
          > thehl1970 <> wrote:
          >
          > : OK, I am writing my first PERL script. While a highly-seasoned
          > : software developer, I'm new to PERL and somewhat new to CGI. (I've
          > : written CGI's in COBOL, believe it or not!)
          > :
          > : I am testing using Apache 2.0 and firefox as my web browser. I
          > : downloaded the guestbook.cgi app to clone from. I have written and
          > : tested my script and was happy with it. Now I run it from my web
          > : client and what I see on my screen is the HTML source. How can this
          > : be?
          >
          > This is REALLY the wrong script to be using as a model. Check
          > Google for the NMS perl scripts. NMS should have a guestbook script
          > which is written using more modern perl programming techniques. I
          > don't even want to look at this stuff. Blech!
          >
          > HTH,
          >
          > Charles K. Clarkson
          > --
          > Mobile Homes Specialist
          > 254 968-8328
        • Scot Robnett
          Actually, what Charles is suggesting IS helpful. The script you are learning from uses and old library and older, less efficient programming techniques. Here
          Message 4 of 14 , Jul 3, 2005
          • 0 Attachment
            Actually, what Charles is suggesting IS helpful. The script you are
            learning from uses and old library and older, less efficient
            programming techniques. Here is what I suggest:

            1. Follow Charles' advice and go get the NMS guestbook script. You
            will find better code to replicate here.

            2. If you don't have a recent version of Perl, download the latest
            stable release for your OS. Rather than using the cgi-lib.pl library,
            you REALLY need to be using the CGI.pm module. It will make your life
            as a programmer much simpler and it will also help you write more
            secure, reusable code.

            3. Learn a module like HTML::Template
            (http://search.cpan.org/~samtregar/HTML-Template-2.7/Template.pm)
            which will keep your HTML separate from your code. This will make it
            not only easier for you to maintain, but you will be able to change
            templates without changing your scripts, and anyone that has to pick
            up where you left off will have an easier go of it.

            4. Browse around CPAN (www.cpan.org) for modules that have already
            been built for your particular application. Most of these have been
            tested and re-tested by the community at large, and if they haven't,
            the documentation will usually tell you so. You can learn by looking
            at different sections of these modules to see how they're doing what
            they do. In the meantime, you can build more robust applications much
            faster.

            5. Please repeat after me: CPAN is your friend. We love CPAN. CPAN
            good. You are getting very sleeeeeeeeeeeeeeeeeepyyyyyyyy......

            I'm glad to see that you're trying to learn. We're just trying to help
            you learn the right stuff from the beginning so you don't have to
            break bad habits later.

            Scot Robnett
            inSite Internet Solutions
            scot@...



            -----Original Message-----
            From: perl-beginner@yahoogroups.com
            [mailto:perl-beginner@yahoogroups.com]On Behalf Of thehl1970
            Sent: Sunday, July 03, 2005 2:16 PM
            To: perl-beginner@yahoogroups.com
            Subject: Re: [PBML] View Source Code?????


            I would appreciate any HELPFUL advice you may have. If there are
            things in my script you would like to suggest improvement on, I will
            be more than happy to listen to them.

            Thanks.

            --- In perl-beginner@yahoogroups.com, "Charles K. Clarkson"
            <cclarkson@h...> wrote:
            > thehl1970 <> wrote:
            >
            > : OK, I am writing my first PERL script. While a highly-seasoned
            > : software developer, I'm new to PERL and somewhat new to CGI. (I've
            > : written CGI's in COBOL, believe it or not!)
            > :
            > : I am testing using Apache 2.0 and firefox as my web browser. I
            > : downloaded the guestbook.cgi app to clone from. I have written and
            > : tested my script and was happy with it. Now I run it from my web
            > : client and what I see on my screen is the HTML source. How can
            this
            > : be?
            >
            > This is REALLY the wrong script to be using as a model. Check
            > Google for the NMS perl scripts. NMS should have a guestbook script
            > which is written using more modern perl programming techniques. I
            > don't even want to look at this stuff. Blech!
            >
            > HTH,
            >
            > Charles K. Clarkson
            > --
            > Mobile Homes Specialist
            > 254 968-8328




            Unsubscribing info is here:
            http://help.yahoo.com/help/us/groups/groups-32.html
            Yahoo! Groups Links








            --
            No virus found in this incoming message.
            Checked by AVG Anti-Virus.
            Version: 7.0.323 / Virus Database: 267.8.8/37 - Release Date: 7/1/2005

            --
            No virus found in this outgoing message.
            Checked by AVG Anti-Virus.
            Version: 7.0.323 / Virus Database: 267.8.8/37 - Release Date: 7/1/2005
          • Charles K. Clarkson
            ... IMO, a good perl CGI script has warnings and strictures turned on. Since you are using Apache 2.0, we can assume you are also using a new version of perl.
            Message 5 of 14 , Jul 3, 2005
            • 0 Attachment
              thehl1970 <> wrote:

              : I would appreciate any HELPFUL advice you may have. If there are
              : things in my script you would like to suggest improvement on, I
              : will be more than happy to listen to them.

              : #! /usr/bin/perl

              IMO, a good perl CGI script has warnings and strictures
              turned on. Since you are using Apache 2.0, we can assume you are
              also using a new version of perl. The "-T" on the command line
              turns on taint checking.

              #! /usr/bin/perl -T

              use strict;
              use warnings;


              : # Global Variables:

              Good perl programming practices frown on the use of global
              variables. Modern perl CGI scripts avoid global variables like the
              plague. Just don't do this.


              : require 'cgi-lib.pl';

              Modern perl CGI scripts use the CGI.pm module.

              use CGI '-noxhtml';


              : print 'Start';

              This will not work through a server. You have not yet printed
              the header. (Actually, it might work if cgi-lib.pl prints the
              header automatically, but I doubt it.) You should be getting a
              server error, not a program listing.

              Using the object oriented interface to CGI.pm, you would want
              something like this. Read the CGI module documentation for
              details.

              use CGI '-noxhtml';

              my $q = CGI->new();

              print
              $q->header(),
              $q->start_html('guestbook'),
              $q->h1('Start');


              : # Messages for later use
              : %UsersMessages = ("UN_IDENT", "An un-identified error occured in:",
              : "Back" , "Back");


              With strictures enforced, global variables need to be file
              scoped. Using single quotes, fat commas, white space, and lexical
              variables we could do this.

              my %UsersMessages = (
              UN_IDENT => 'An un-identified error occurred in:',
              Back => 'Back'
              );


              : # Error codes
              : $ERR_UN_IDENT=1024;

              You're not using this in the script.


              : @date= localtime(time);
              : @Months =
              :
              ('January','February','March','April','May','June','July','August','Septembe
              r','October','November','December');
              : $date[5] += 1900;
              : $Time = "$date[3] $Months[$date[4]] $date[5]";

              These are also not used in this script. You might checkout the
              POSIX function strftime(). It's interface is much easier to use
              than this one.

              use POSIX 'strftime';

              my $Time = strftime( '%d %B %Y', localtime() );


              : ###############################################################
              : # This is main processing routine
              : ###############################################################

              With the CGI module, this might look like this.

              if ( $q->param() ) {

              if ( $q->param('action') = 'something' ) {
              # Do something.

              } elsif ( $q->param('action') = 'something_else' ) {
              # Do something else.
              }


              } else {
              # Do whatever is done when no form parameters are passed.
              }

              The reason I mention NMS is because almost all of your script
              is wrong. You are using programming practices that are dated or
              unusual for modern perl. I don't know why your source code is
              displaying in the browser, but I do know that this code is not a
              good place to starting place for learning perl CGI programming.


              HTH,

              Charles K. Clarkson
              --
              Mobile Homes Specialist
              254 968-8328
            • Paul Alapatt
              Hi, This generally occurs for two reasons: 1. Your CGI Content-type is incorrect 2. Your web server fails to understand what is the content-type and defaults
              Message 6 of 14 , Jul 3, 2005
              • 0 Attachment
                Hi,

                This generally occurs for two reasons:

                1. Your CGI Content-type is incorrect
                2. Your web server fails to understand what is the content-type and defaults
                it to text/plain

                So make sure that your script below prints the following:

                print "Content-type:text/html\n\n";

                so, where or the equivalent.

                Alternatively check if the .cgi script type interpretation in the httpd.conf
                is fine in Apache.

                Take care,
                Paul Alapatt

                http://www.bernardlabs.org/

                ________________________________________
                From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com]
                On Behalf Of thehl1970
                Sent: Sunday, July 03, 2005 9:13 PM
                To: perl-beginner@yahoogroups.com
                Subject: [PBML] View Source Code?????

                OK, I am writing my first PERL script. While a highly-seasoned
                software developer, I'm new to PERL and somewhat new to CGI. (I've
                written CGI's in COBOL, believe it or not!)

                I am testing using Apache 2.0 and firefox as my web browser. I
                downloaded the guestbook.cgi app to clone from. I have written and
                tested my script and was happy with it. Now I run it from my web
                client and what I see on my screen is the HTML source. How can this be?

                I then immediately attempted running guestbook.cgi and it works fine.
                Go back to mine, and I get source code. I thought maybe something was
                funny in the HTML, so I saved it off to an html file and opened it and
                it worked fine. Any ideas as to where to go from here?

                Here is my script. It's not finished so you'll see some strange code
                that doesn't do anything.

                #! /usr/bin/perl
                ######################################################################
                # rex_config
                # Copyright 2005 Heavyweight Software
                ######################################################################
                # Function : performs configuration for the rex conversion utility
                ######################################################################
                ##################### license & copyright header #####################
                #                                                                    #
                #                Copyright (c) 2005 by Heavyweight Software
                #                                                                    #
                #  This program is distributed as part of the rex package. All
                #  reserved.
                ################### end license & copyright header ###################
                ######################################################################
                # Global Variables:
                ######################################################################
                require 'cgi-lib.pl';

                print 'Start';

                # Messages for later use
                %UsersMessages = ("UN_IDENT", "An un-identified error occured in:",
                                  "Back"   , "Back");
                # Error codes
                $ERR_UN_IDENT=1024;

                @date= localtime(time);
                @Months =
                ('January','February','March','April','May','June','July','August','Septembe
                r','October','November','December');
                $date[5] += 1900;
                $Time = "$date[3] $Months[$date[4]] $date[5]";

                ######################################################################
                # This is main processing routine
                ######################################################################

                $Ret = &ReadParse(*input);
                if ($Ret==0)
                {
                    $Page = 0;
                } elsif ($Ret>0)
                {
                    $Page = $input{'Page'};
                } else
                {
                    &Error($UsersMessages{'UN_IDENT'},ERR_UN_IDENT);
                    exit;
                }

                print &StoreValues($Page);

                $Page++;

                &PrintConfigPage($Page);

                exit;
                ######################################################################
                # End of main routine
                ######################################################################

                ######################################################################
                # Sub-routines here
                ######################################################################

                # Generates the back button for error pages
                sub Back
                {
                    return <<EOF;
                    <FORM>
                      <BR>
                      <BR>
                      <BR>
                      <TABLE WIDTH="100%">
                        <TR>
                          <TD WIDTH="75%" ALIGN="Right">
                            <INPUT TYPE="image" BORDER=0 ONCLICK="history.go(-1);"
                                   NAME="goback" SRC="images/next.png"/>
                          </TD>
                          <TD>
                             
                          </TD>
                        </TR>
                      </TABLE>
                    </FORM>
                EOF
                }

                # error routine generates an error page
                sub Error
                {
                      my($ErrorText, $Exit) = @_;
                    print &HTMLHeader($ErrorText);
                      print &Back($GuestbookURL);
                      print &HTMLEnd;
                      if($Exit) { exit; }
                }

                # prints the Html footer
                sub HtmlEnd
                {
                    return <<EOF;

                    <BR> <BR>

                    <CENTER><P class="app_name">
                      RE Transform Converter--Configuration Utility
                    </P></CENTER>
                  <CENTER><BR><BR>
                      <EM>© Copyright 2005 <A
                HREF="http://www.HeavyweightSoftware.com/Rex">Heavyweight
                Software</A>. All rights reserved.</EM>
                  </CENTER>
                </BODY></HTML>
                EOF
                }

                # prints the Html Header
                sub HtmlHeader
                {
                      my($Title) = @_;
                      $HeadTitle = $Title;
                      $HeadTitle =~ s/\<\w\w*\>/ /gi;
                    return <<EOF;
                Content-type: text/html

                <HTML>
                <HEAD>
                  <TITLE>$HeadTitle</TITLE>
                  <META HTTP-EQUIV="content-type" CONTENT="text/html;charset=iso-8859-1"/>
                  <META NAME="ROBOTS" CONTENT="NOINDEX, FOLLOW"/>
                  <META NAME="description" CONTENT="none"/>
                  <META NAME="keywords" CONTENT="none"/>
                  <META NAME="Author" CONTENT="Heavyweight
                Software--www.HeavyweightSoftware.com"/>
                  <META NAME="GENERATOR" CONTENT="CGI Script by Heavyweight Software"/>

                  <LINK REL="stylesheet" HREF="heavyweight.css" TYPE="text/css">
                </HEAD>
                <BODY BGCOLOR="#FFFFFF">
                  <CENTER><H1>$HeadTitle</H1></CENTER>
                EOF
                }

                # Generates the approriate configuration page
                sub PrintConfigPage
                {
                      my($PageNo) = @_;
                    print &HtmlHeader('Rex Configuration--Page '.$PageNo);

                    print <<EOF;
                    <FORM ACTION="/cgi-bin/rex_config.cgi" MEHTOD="post"
                NAME="Configure$PageNo">
                      <INPUT TYPE="hidden" NAME="Page" VALUE="$PageNo"/> <BR>

                      <CENTER>
                        <H2>Choose MLS type</H2>
                        <SELECT NAME="IdxType" WIDTH="100%">
                          <OPTION VALUE="Voyager2">FNIS Voyager 2</OPTION>
                          <OPTION VALUE="BG">The Bowling Green one</OPTION>
                        </SELECT>
                      </CENTER>

                      <BR>
                      <BR>
                      <BR>
                      <TABLE WIDTH="100%">
                        <TR>
                          <TD WIDTH="75%" ALIGN="Right">
                            <INPUT TYPE="image" BORDER=0 NAME="doit"
                SRC="images/next.png"/>
                          </TD>
                          <TD>
                             
                          </TD>
                        </TR>
                      </TABLE>

                    </FORM>

                EOF

                    print &HtmlEnd;
                }

                # Stores values to the configuration file
                sub StoreValues
                {
                      my($PageNo) = @_;
                }







                Unsubscribing info is here:
                http://help.yahoo.com/help/us/groups/groups-32.html


                ________________________________________
                YAHOO! GROUPS LINKS

                •  Visit your group "perl-beginner" on the web.
                 
                •  To unsubscribe from this group, send an email to:
                 perl-beginner-unsubscribe@yahoogroups.com
                 
                •  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

                ________________________________________
              • thehl1970
                Thank you, Charles. This is EXCELLENT feedback. With your comments and a fresh perspective I have reviewed my code. The print Start was a debugging statement
                Message 7 of 14 , Jul 4, 2005
                • 0 Attachment
                  Thank you, Charles. This is EXCELLENT feedback. With your comments and
                  a fresh perspective I have reviewed my code. The print 'Start' was a
                  debugging statement I put in and never took back out. I needed someone
                  else to see that one for me as this was probably half the problem.

                  The other half appears to have been:

                  print &StoreValues($Page);

                  Which I'd cloned in clear stupidity as this is supposed to just store
                  the values in an XML file and not return anything. Since I was
                  printing the return value, which was probably a null, this was going
                  out first in the HTML stream and probably causing my stupid problem.

                  A submitter suggested I use HTML::Template, which I began doing, but
                  it requires installation on the production system. I am writing
                  shrink-wrap software and, so, choose to avoid this.

                  Will CGI.pm require installation as well? With the cgi-lib.pl
                  solution, I just copy that into my cgi-bin directory and I'm finished.

                  I will review CGI.pm.

                  Thanks again for all your counsel, advice, help.

                  --- In perl-beginner@yahoogroups.com, "Charles K. Clarkson"
                  <cclarkson@h...> wrote:
                  > thehl1970 <> wrote:
                  >
                  > : I would appreciate any HELPFUL advice you may have. If there are
                  > : things in my script you would like to suggest improvement on, I
                  > : will be more than happy to listen to them.
                  >
                  > : #! /usr/bin/perl
                  >
                  > IMO, a good perl CGI script has warnings and strictures
                  > turned on. Since you are using Apache 2.0, we can assume you are
                  > also using a new version of perl. The "-T" on the command line
                  > turns on taint checking.
                  >
                  > #! /usr/bin/perl -T
                  >
                  > use strict;
                  > use warnings;
                  >
                  >
                  > : # Global Variables:
                  >
                  > Good perl programming practices frown on the use of global
                  > variables. Modern perl CGI scripts avoid global variables like the
                  > plague. Just don't do this.
                  >
                  >
                  > : require 'cgi-lib.pl';
                  >
                  > Modern perl CGI scripts use the CGI.pm module.
                  >
                  > use CGI '-noxhtml';
                  >
                  >
                  > : print 'Start';
                  >
                  > This will not work through a server. You have not yet printed
                  > the header. (Actually, it might work if cgi-lib.pl prints the
                  > header automatically, but I doubt it.) You should be getting a
                  > server error, not a program listing.
                  >
                  > Using the object oriented interface to CGI.pm, you would want
                  > something like this. Read the CGI module documentation for
                  > details.
                  >
                  > use CGI '-noxhtml';
                  >
                  > my $q = CGI->new();
                  >
                  > print
                  > $q->header(),
                  > $q->start_html('guestbook'),
                  > $q->h1('Start');
                  >
                  >
                  > : # Messages for later use
                  > : %UsersMessages = ("UN_IDENT", "An un-identified error occured in:",
                  > : "Back" , "Back");
                  >
                  >
                  > With strictures enforced, global variables need to be file
                  > scoped. Using single quotes, fat commas, white space, and lexical
                  > variables we could do this.
                  >
                  > my %UsersMessages = (
                  > UN_IDENT => 'An un-identified error occurred in:',
                  > Back => 'Back'
                  > );
                  >
                  >
                  > : # Error codes
                  > : $ERR_UN_IDENT=1024;
                  >
                  > You're not using this in the script.
                  >
                  >
                  > : @date= localtime(time);
                  > : @Months =
                  > :
                  >
                  ('January','February','March','April','May','June','July','August','Septembe
                  > r','October','November','December');
                  > : $date[5] += 1900;
                  > : $Time = "$date[3] $Months[$date[4]] $date[5]";
                  >
                  > These are also not used in this script. You might checkout the
                  > POSIX function strftime(). It's interface is much easier to use
                  > than this one.
                  >
                  > use POSIX 'strftime';
                  >
                  > my $Time = strftime( '%d %B %Y', localtime() );
                  >
                  >
                  > : ###############################################################
                  > : # This is main processing routine
                  > : ###############################################################
                  >
                  > With the CGI module, this might look like this.
                  >
                  > if ( $q->param() ) {
                  >
                  > if ( $q->param('action') = 'something' ) {
                  > # Do something.
                  >
                  > } elsif ( $q->param('action') = 'something_else' ) {
                  > # Do something else.
                  > }
                  >
                  >
                  > } else {
                  > # Do whatever is done when no form parameters are passed.
                  > }
                  >
                  > The reason I mention NMS is because almost all of your script
                  > is wrong. You are using programming practices that are dated or
                  > unusual for modern perl. I don't know why your source code is
                  > displaying in the browser, but I do know that this code is not a
                  > good place to starting place for learning perl CGI programming.
                  >
                  >
                  > HTH,
                  >
                  > Charles K. Clarkson
                  > --
                  > Mobile Homes Specialist
                  > 254 968-8328
                • Charles K. Clarkson
                  ... You might also look into CGI::Application which uses HTML::Template by default. HTML::Template is pure perl. There is no requirement to install pure perl
                  Message 8 of 14 , Jul 4, 2005
                  • 0 Attachment
                    thehl1970 <> wrote:

                    : A submitter suggested I use HTML::Template, which I began doing,
                    : but it requires installation on the production system. I am
                    : writing shrink-wrap software and, so, choose to avoid this.

                    You might also look into CGI::Application which uses
                    HTML::Template by default.

                    HTML::Template is pure perl. There is no requirement to
                    install pure perl modules. All you need to do to use it is to copy
                    it to your cgi-bin directory in a sub directory named 'HTML'.

                    Directories:

                    /cgi-bin/
                    myscript.pl

                    HTML/
                    Template.pm

                    In myscript.pl use the 'lib' module to prepend the current
                    directory ('.') to @INC, the array of directories that perl uses
                    to find modules.

                    use lib '.';
                    use HTML::Template;


                    : Will CGI.pm require installation as well? With the cgi-lib.pl
                    : solution, I just copy that into my cgi-bin directory and I'm
                    : finished.

                    CGI.pm is a core module. It should be included in all modern
                    perl installations. You might want to add the module locally like
                    we did above to guarantee each installation is using the same
                    version, but that is unlikely to be a problem.

                    There is a decided advantage to using modules over the use of
                    scripts like cgi-lib.pl. It only seems advantageous to use it now
                    because you are not experienced with perl.


                    : I will review CGI.pm.
                    :
                    : Thanks again for all your counsel, advice, help.

                    You are welcome.

                    HTH,

                    Charles K. Clarkson
                    --
                    Mobile Homes Specialist
                    254 968-8328
                  • thehl1970
                    Evidently, there is a requirement to install CGI.pm. If you run make install, it registers it s presence by modifying a file in the perl interpreter directory.
                    Message 9 of 14 , Jul 4, 2005
                    • 0 Attachment
                      Evidently, there is a requirement to install CGI.pm. If you run make
                      install, it registers it's presence by modifying a file in the perl
                      interpreter directory. If you simply make the CGI.pm and do not run
                      the install, the copy the CGI.pm file into the HTML directory, running
                      a PERL program that accesses this generates an error. If you move it
                      to the same directory as your script, same exact problem.

                      I did not say that doing it cgi-lib.pl is simpler to code. I am a
                      veteran software engineer and work hard to select the right solution
                      for a given problem. If CGI.pm would have worked as you described it
                      without modifying the existing system, I would have been happy to
                      adopt this more modern solution.

                      The problem is that, with shrink wrapped software being installed on
                      web server, I do not have the luxury of modifying system files on the
                      server. I must use what is there. While I'm sure you're right that 90%
                      of professional web servers do not have this installed, supporting the
                      other 10% will eat up all of the profits of my sale and significantly
                      diminish my quality of work life.

                      If you can lend a hand as to how to deploy CGI.pm along with my
                      application without modifying system files, I will adopt this as my
                      long-term solution. If not, though, I feel I must continue to use the
                      older cgi-lib.pl approach, as ugly as it is.

                      Thanks.

                      --- In perl-beginner@yahoogroups.com, "Charles K. Clarkson"
                      <cclarkson@h...> wrote:
                      > thehl1970 <> wrote:
                      >
                      > : A submitter suggested I use HTML::Template, which I began doing,
                      > : but it requires installation on the production system. I am
                      > : writing shrink-wrap software and, so, choose to avoid this.
                      >
                      > You might also look into CGI::Application which uses
                      > HTML::Template by default.
                      >
                      > HTML::Template is pure perl. There is no requirement to
                      > install pure perl modules. All you need to do to use it is to copy
                      > it to your cgi-bin directory in a sub directory named 'HTML'.
                      >
                      > Directories:
                      >
                      > /cgi-bin/
                      > myscript.pl
                      >
                      > HTML/
                      > Template.pm
                      >
                      > In myscript.pl use the 'lib' module to prepend the current
                      > directory ('.') to @INC, the array of directories that perl uses
                      > to find modules.
                      >
                      > use lib '.';
                      > use HTML::Template;
                      >
                      >
                      > : Will CGI.pm require installation as well? With the cgi-lib.pl
                      > : solution, I just copy that into my cgi-bin directory and I'm
                      > : finished.
                      >
                      > CGI.pm is a core module. It should be included in all modern
                      > perl installations. You might want to add the module locally like
                      > we did above to guarantee each installation is using the same
                      > version, but that is unlikely to be a problem.
                      >
                      > There is a decided advantage to using modules over the use of
                      > scripts like cgi-lib.pl. It only seems advantageous to use it now
                      > because you are not experienced with perl.
                      >
                      >
                      > : I will review CGI.pm.
                      > :
                      > : Thanks again for all your counsel, advice, help.
                      >
                      > You are welcome.
                      >
                      > HTH,
                      >
                      > Charles K. Clarkson
                      > --
                      > Mobile Homes Specialist
                      > 254 968-8328
                    • J.E. Cripps
                      ... Umm, if you don t have CGI.pm isn t your perl out of date? Or something less than the standard installation? Complain to whoever _can_ modify the system
                      Message 10 of 14 , Jul 4, 2005
                      • 0 Attachment
                        > If you can lend a hand as to how to deploy CGI.pm along with my
                        > application without modifying system files, I will adopt this as my
                        > long-term solution. If not, though, I feel I must continue to use the
                        > older cgi-lib.pl approach, as ugly as it is.

                        Umm, if you don't have CGI.pm isn't your perl out
                        of date? Or something less than the standard installation?
                        Complain to whoever _can_ modify the system files.

                        perldoc perlmodlib

                        lists the those that are standard, and CGI is one.

                        perldoc CGI

                        should yield the documentation that comes with CGI.pm

                        There's much more; there are entire books about CGI.pm
                      • thehl1970
                        CGI.pm appears to be an add-in module as my version of perl is 5.8.5. I can t speak to whether it should have been included as it appears not to be. And you re
                        Message 11 of 14 , Jul 4, 2005
                        • 0 Attachment
                          CGI.pm appears to be an add-in module as my version of perl is 5.8.5.
                          I can't speak to whether it should have been included as it appears
                          not to be.

                          And you're missing the point about speaking to the person who can
                          change the files. I am selling shrink-wrap software. I have no control
                          over the site it will be installed on. It will be installed by the ISP
                          customer on the ISP's server. If I make my package dependent on an
                          "optional" (regardless of how standard) package, then I end up doing
                          tech support and playing broker between my client and their tech
                          support. I can't think of a faster way to diminish the pleasure of
                          running my own software company.

                          I would really like to use the latest and greatest technologies, but
                          it appears to be intractable in this situation unless someone can
                          counsel me on how it can be done.

                          Thanks!

                          --- In perl-beginner@yahoogroups.com, "J.E. Cripps" <cycmn@n...> wrote:
                          >
                          > > If you can lend a hand as to how to deploy CGI.pm along with my
                          > > application without modifying system files, I will adopt this as my
                          > > long-term solution. If not, though, I feel I must continue to use the
                          > > older cgi-lib.pl approach, as ugly as it is.
                          >
                          > Umm, if you don't have CGI.pm isn't your perl out
                          > of date? Or something less than the standard installation?
                          > Complain to whoever _can_ modify the system files.
                          >
                          > perldoc perlmodlib
                          >
                          > lists the those that are standard, and CGI is one.
                          >
                          > perldoc CGI
                          >
                          > should yield the documentation that comes with CGI.pm
                          >
                          > There's much more; there are entire books about CGI.pm
                        • J.E. Cripps
                          ... so is mine. What happens when you try perldoc CGI ... True but CGI.pm has been Standard for quite a while, and your client really should have it. I
                          Message 12 of 14 , Jul 4, 2005
                          • 0 Attachment
                            > CGI.pm appears to be an add-in module as my version of perl is 5.8.5.
                            > I can't speak to whether it should have been included as it appears
                            > not to be.

                            so is mine. What happens when you try

                            perldoc CGI

                            > If I make my package dependent on an "optional" (regardless of how
                            > standard) package, then I end up doing tech support and playing broker
                            > between my client and their tech support.

                            True but CGI.pm has been "Standard" for quite a while, and
                            your client really should have it. I mean, there were
                            "Porting cgi-lib.pl Scripts to CGI.pm"
                            http://search.cpan.org/src/LDS/CGI.pm-3.10/cgi-lib_porting.html
                            written in 1998. AIUI, it's been around as long as Perl 5.
                          • Mike Southern
                            LOL! You should check out the cpan archives. They are full of perl modules sometimes so riddled with dependencies that the five minutes it takes to actually
                            Message 13 of 14 , Jul 4, 2005
                            • 0 Attachment
                              LOL! You should check out the cpan archives. They are full of perl modules
                              sometimes so riddled with dependencies that the five minutes it takes to
                              actually perform the install is overwhelmed by the 3 hours it takes to find
                              the correct required modules.

                              That's a fact of perl development, it seems.

                              It also seems your 5.8.5 may be missing something; CGI.pm is part of the
                              standard package. Not optional.

                              If you are using something else, then your package should indicate this -
                              but before you do that I would seriously suggest that you find a machine
                              that *does* use cgi.pm and test your package against that.

                              If you are making an older function suite an install requirement, and there
                              is a conflict between old and new then you really won't have a customer
                              support problem at all; folk just won't use the software.

                              > I would really like to use the latest and greatest technologies, but
                              > it appears to be intractable in this situation unless someone can
                              > counsel me on how it can be done.

                              Not so sure it's latest and greatest. The module goes back to November 98.

                              http://search.cpan.org/~lds/CGI.pm-3.10/

                              I would counsel that you get yourself a fresh perl current download, install
                              it, and test your application using cgi.pm



                              On 7/4/05 7:08 PM, thehl1970 at thehl1970@... wrote:

                              > CGI.pm appears to be an add-in module as my version of perl is 5.8.5.
                              > I can't speak to whether it should have been included as it appears
                              > not to be.
                              >
                              > And you're missing the point about speaking to the person who can
                              > change the files. I am selling shrink-wrap software. I have no control
                              > over the site it will be installed on. It will be installed by the ISP
                              > customer on the ISP's server. If I make my package dependent on an
                              > "optional" (regardless of how standard) package, then I end up doing
                              > tech support and playing broker between my client and their tech
                              > support. I can't think of a faster way to diminish the pleasure of
                              > running my own software company.
                              >
                              > I would really like to use the latest and greatest technologies, but
                              > it appears to be intractable in this situation unless someone can
                              > counsel me on how it can be done.
                              >
                              > Thanks!
                              >
                              > --- In perl-beginner@yahoogroups.com, "J.E. Cripps" <cycmn@n...> wrote:
                              >>
                              >>> If you can lend a hand as to how to deploy CGI.pm along with my
                              >>> application without modifying system files, I will adopt this as my
                              >>> long-term solution. If not, though, I feel I must continue to use the
                              >>> older cgi-lib.pl approach, as ugly as it is.
                              >>
                              >> Umm, if you don't have CGI.pm isn't your perl out
                              >> of date? Or something less than the standard installation?
                              >> Complain to whoever _can_ modify the system files.
                              >>
                              >> perldoc perlmodlib
                              >>
                              >> lists the those that are standard, and CGI is one.
                              >>
                              >> perldoc CGI
                              >>
                              >> should yield the documentation that comes with CGI.pm
                              >>
                              >> There's much more; there are entire books about CGI.pm
                              >
                              >
                              >
                              >
                              > Unsubscribing info is here:
                              > http://help.yahoo.com/help/us/groups/groups-32.html
                              > Yahoo! Groups Links
                              >
                              >
                              >
                              >
                              >
                              >
                            • Charles K. Clarkson
                              ... You need to read more about modules and installing modules. I named the directory holding Template.pm HTML because the module is named HTML::Template. Look
                              Message 14 of 14 , Jul 4, 2005
                              • 0 Attachment
                                thehl1970 <> wrote:

                                : Evidently, there is a requirement to install CGI.pm. If you run
                                : make install, it registers it's presence by modifying a file in
                                : the perl interpreter directory. If you simply make the CGI.pm
                                : and do not run the install, the copy the CGI.pm file into the
                                : HTML directory, running a PERL program that accesses this
                                : generates an error. If you move it to the same directory as your
                                : script, same exact problem.

                                You need to read more about modules and installing modules. I
                                named the directory holding Template.pm HTML because the module is
                                named HTML::Template. Look at the first line of that module.

                                package HTML::Template;

                                Since CGI.pm is not named HTML::CGI, perl will not look for it
                                in the HTML directory. It would look for it in the current
                                directory, which is probably /cgi-bin/.


                                : If you can lend a hand as to how to deploy CGI.pm along with my
                                : application without modifying system files, I will adopt this as
                                : my long-term solution. If not, though, I feel I must continue to
                                : use the older cgi-lib.pl approach, as ugly as it is.

                                In your case I would change the directory hierarchy to this.

                                /cgi-bin/
                                MyScript.pl

                                modules/
                                CGI.pm

                                CGI/
                                Util.pm

                                HTML/
                                Template.pm

                                In your scripts add the following near the top.

                                use lib 'modules';

                                Or (I didn't test):

                                use lib './modules';

                                In one IIS installation I use an absolute path.


                                The Util.pm module above is needed by CGI.pm. At the top of
                                that file is the following line. See how it works now?

                                package CGI::Util;


                                When using other modules mentally change the :: to / (or
                                whatever your directory separator is). Install them using this
                                directory structure.


                                HTH,


                                Charles K. Clarkson
                                --
                                Mobile Homes Specialist
                                254 968-8328
                              Your message has been successfully submitted and would be delivered to recipients shortly.