david.jackson has asked for the wisdom of the Perl Monks concerning the following question:

Storable: freeze/unfreeze
Revised: Storable data retrieval

I would appreciate any advice on how to imput this script, it pretty basic,send email and creates a file called server.log.

Furture goals include: 1) DBM and or Storble for data storage Thanks for your time.

#!/usr/bin/perl -wT use strict; use diagnostics; use CGI qw(:all); # my $GUESTBOOKFILE="/tmp/server.log"; # print header(); print start_html(-title=>'The Light Dawns'); print h4("Take the parms and run"); print p("Node Name: ") . p(param('hostess')); print p("IPAddr: ") . p(param('ipaddr')); print p("PrimarySA: ") . p(param('primarysa')); print p("Funcition: "); print p(param('funct')); print "end_html"; # Fire off email # open (MAIL,"|/var/qmail/bin/qmail-inject"); print MAIL "To: <davej\@pickledbeans.com>\n"; print MAIL "From <bitbucket\@pickledbeans.com>\n"; print MAIL "Subject: " . param('hostess') . " Report\n"; print MAIL "Node Name: " . param('hostess') . "\n"; print MAIL "IP Addr: " . param('ipaddr') . "\n"; print MAIL "Primary SA: " . param('primarysa') . "\n"; print MAIL "Function:\n"; print MAIL param('funct') . "\n"; close MAIL; print end_html(); my ($date); open (LOG,">>$GUESTBOOKFILE"); flock(LOG, 2); #print LOG join(":",$date,param($_)) ."\n"; #save_parameters(*LOG); print LOG join(":",param('hostess') , param('ipaddr'), param('primarysa'), param('funct')); print LOG "\n"; close (LOG); exit;

Replies are listed 'Best First'.
Re: Rev: CGI backup
by Masem (Monsignor) on Oct 17, 2001 at 22:43 UTC
    One thing that could help improve speed, though I doubt this is an issue, is that instead of doing:
    print p("Node Name: ") . p(param('hostess'));
    it's typically faster to do
    print p("Node Name: ") , p(param('hostess'));
    (Note the change to the comma) as the engine avoids some extra temporary variable creation when you do this.

    And if you go this route, you can simplify your code in both the html delievery and mail delievery parts with judicious use of commas:

    print header(), start_html(-title=>'The Light Dawns'), h4("Take the parms and run"), p("Node Name: ") , p(param('hostess')), # etc...

    -----------------------------------------------------
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
    It's not what you know, but knowing how to find it if you don't know that's important

      Thanks for the suggestion, I'll do it. David