[Novalug] a perl question
Megan Larko
larkoc@iges.org
Fri Jan 5 12:47:54 EST 2007
Igor Birman wrote:
Thank you. That got rid of some of the messages. I still have the same error message for every
instance of $FORM{'$myvar'}. I put the my %FORM = ""' and the my @pairs = (); (my stupidity, I
could not remember the % or () syntax---Thanks again Igor). Now supposedly everything is
initialized but writing it out generates one error warning per instance $FOMR{'$myvar'}.
OUTPUT:
./news.data.test.cgi
Odd number of elements in hash assignment at ./news.data.test.cgi line 35.
Content-type: text/html
<Head><Title>NASA NEWS Investigators Data Table</Title></Head><BODY>
Use of uninitialized value in read at ./news.data.test.cgi line 44.
Use of uninitialized value in string eq at ./news.data.test.cgi line 56.
Use of uninitialized value in string eq at ./news.data.test.cgi line 57.
<IMG SRC="header_news.jpg" ALT="NEWS logo" HEIGHT="100" WIDTH="600"><BR>
Your form submission to NEWS Data has been sent.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 66.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 67.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 68.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 74.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 75.
<P>
<CENTER>
Your dataset description update to the NASA Energy and Watercycle site has been received.<BR>
Please visit <A HREF="http://192.239.87.211/news.data.table.html">the NEWS data
table to view the current descriptions (and holdings)</A><P>
The current time is: Fri Jan 5 12:42:10 2007 <BR>
<A HREF="http://www.nasa-news.org/">Return to NEWS Page</A>
</CENTER>
</BODY>
</HTML>
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 98.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 98.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 98.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 98.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 98.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 98.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 98.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 98.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 98.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 98.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 98.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 98.
Use of uninitialized value in concatenation (.) or string at ./news.data.test.cgi line 98.
> Megan,
>
> You need to initialize the FORM as a hash type and pairs as an array.
> Do this:
>
> my %FORM = "";
> my @pairs = ();
>
> Igor
>
-------------- next part --------------
#!/usr/bin/perl -w -T
use strict;
### Unbuffer the output ###
use FileHandle;
STDOUT->autoflush(1);
my $mytime = scalar(localtime());
my $server = $ENV{'SERVER_NAME'};
my $host = $ENV{'REMOTE_HOST'};
my $page = $ENV{'SCRIPT_NAME'};
my $mailprog = '/usr/sbin/sendmail';
#Meg my $mailprog = '/usr/bin/mail';
#Meg my $recipient = 'larkoc@cola.iges.org';
my $recipient = 'larkoc';
# Initialize vars
my $buffer = "";
my $pair = "";
my $dir1 = "";
my $name ="";
my $value ="";
my $ContactEmail ="";
my $datatype ="";
my $dataname ="";
my $dataDesc ="";
my $dataX ="";
my $dataY ="";
my $dataCtr ="";
my $dataStartLat ="";
my $dataStartLon ="";
my $dataEndLat ="";
my $dataEndLon ="";
my $dataMeet ="";
my $dataFormat ="";
my $dataURL ="";
my $mybrowser ="";
my %FORM = "";
my @pairs = ();
print "Content-type: text/html\n\n";
# Flush stdout buffer
$| = 1;
print "<Head><Title>NASA NEWS Investigators Data Table</Title></Head>";
print "<BODY>\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
if ($FORM{'ContactEmail'} eq "") {$FORM{'ContactEmail'} = '';}
if ($FORM{'name'} eq "") {$FORM{'name'} = '';}
print "<IMG SRC=\"header_news.jpg\" ALT=\"NEWS logo\" HEIGHT=\"100\" WIDTH=\"600\"><BR>\n";
print "Your form submission to NEWS Data has been sent.\n";
open (MAIL, "|$mailprog $recipient ") || die "cant open $mailprog!\n";
print MAIL "Subject: NEWS Data Test\n";
print MAIL "This is a Web page from $FORM{'name'}\n";
print MAIL "\n";
print MAIL "The dataset name: $FORM{'dataname'}\n";
print MAIL "Type: $FORM{'datatype'}.\n\n";
print MAIL "Special Instructions: $FORM{'dataDesc'}\n";
print MAIL "\n";
print MAIL "---------------------------------------------------------------------------\n";
print MAIL "Statistics from: $FORM{'name'} at $FORM{'ContactEmail'}\n";
print MAIL "\n";
print MAIL "The time sent was $mytime \n";
print MAIL "The browser used to access my Web page: $ENV{'HTTP_USER_AGENT'}\n";
print MAIL "The server used to process my Web page: $ENV{'SERVER_NAME'}\n";
print MAIL "---------------------------------------------------------------------------\n";
print MAIL "\n";
close (MAIL);
print "<P>\n";
print "<CENTER>\n";
print "Your dataset description update to the NASA Energy and Watercycle site has been received.<BR> Please visit <A HREF=\"http://192.239.87.211/news.data.table.html\">the NEWS data
table to view the current descriptions (and holdings)</A><P>\n";
print "The current time is: $mytime <BR>\n";
print "<A HREF=\"http://www.nasa-news.org/\">Return to NEWS Page</A>\n";
print "</CENTER>\n";
print "</BODY>\n";
print "</HTML>\n";
# Write updated information to file "survey.response"
if ($mybrowser =~ /MSIE/) {
$dir1="/var/www/response/IE";
} else {
$dir1="/var/www/response";
} # Ends browser if block
if (open(RESPONSE, ">$dir1/survey.response")) {
flock RESPONSE, 2; #lock file to assure only single-access
print RESPONSE "$FORM{'name'} XX $FORM{'ContactEmail'} XX $FORM{'datatype'} XX $FORM{'dataname'} XX $FORM{'dataX'} XX $FORM{'dataY'} XX $FORM{'dataCtr'} XX $FORM{'dataStartLat'} XX $FORM{'dataStartLon'} XX $FORM{'dataMeet'} XX $FORM{'dataEndLat'} XX $FORM{'dataEndLon'} XX $FORM{'dataFormat'} XX $FORM{'dataURL'} XX $FORM{'dataDesc'} \n";
} else { print "<center>Can't open $dir1/response</center>\n";
} #Ends fi open and releases flock
close (RESPONSE);
# Replace old response file with new response file
# Run 4 times to remove all spaces from system data program; replace some with underscore
$mytime =~ s/\s+//;
$mytime =~ s/\s+//;
$mytime =~ s/\s+/_/;
$mytime =~ s/\s+/_/;
#print "mytime $mytime \n\n";
rename ("$dir1/survey.response","$dir1/survey.response.$mytime") || print
"Cannot rename response\n";
### Now chdir response and run pagegen.
chdir $dir1;
# NOTE: system forks then execs; exec just executes
system "ls > infile.list";
system "./pagegen.pl";
More information about the Novalug
mailing list