469,929 Members | 1,751 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

Where's the problem with this code?

Hey, I've been having some trouble debuggin this...I keep getting 500
errors. Would some kind soul be willing to help me?

#!/usr/bin/local/perl

print "Content-type: text/html\n\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{'subitted'} eq 'yes' )
showstats();
else
{
print <<EndOfHTML;
<html><head><title>Test Page</title></head>
<body>
<h2>Select User</h2>
<form action='./logger.cgi' method=post>
<input type=hidden name=submitted value='yes'>
<select name='userid'>

EndOfHTML

opendir(DIR, ".");
@files = readdir(DIR);
closedir(DIR);

foreach $file (@files)
{
if ($file ne "." && $file ne ".." && $file ne "logger.cgi")
{
print "<option value=";
print $file;
print ">";
print $file;
print "</option>\n";
}
}

print "</select><br><input type=submit></form>";

}

sub showstats()
{
%datahash = {};
@timeofday[96];
foreach $entry(@timeofday)
$entry=0;
@tempbuffer;
open(INFILE,$FORM{'userid'});
@data = <INFILE>
foreach $line (@data)
{
@tempbuffer = split(/=/, $line)
$datahash{@tempbuffer[0]}=@tempbuffer[1];
if ($datahash{@tempbuffer[0]}==1)
{
$numberofdays = @tempbuffer[0] % (24 * 60 * 60);
$tod = @tempbuffer[0] - $numberofdays * 24 * 60 *
60;
@timeofday[$tod/(24*4)]++;
}
}


print "<html><head></head><body>\n";
foreach $entry(@timeofday)
{
print "<img src=http://www.shehan.ws/images/red.gif width=4
height=";
print $entry;
print ">\n";
}
}
Jul 19 '05 #1
4 1524
On Sun, 21 Mar 2004 at 01:15 GMT, Sam Snead <sa******@sammy.com> wrote:
Hey, I've been having some trouble debuggin this...I keep getting 500
errors. Would some kind soul be willing to help me?

#!/usr/bin/local/perl
use strict;
use warnings;

print "Content-type: text/html\n\n"; <some code snipped> else
{

print <<EndOfHTML;
<html><head><title>Test Page</title></head>
<body>
<h2>Select User</h2>
<form action='./logger.cgi' method=post>
<input type=hidden name=submitted value='yes'>
<select name='userid'>

EndOfHTML

.. . . . ^^^^^^^^^
Hey! this is not what you said that your here document would end
with. Either move this marker to the left, or change your print
statement as follows:

print <<' EndOfHTML';

I guess that this will cure most of your problems...
Jul 19 '05 #2
In article <sl**********************@195-86-124-242.dsl.easynet.nl>,
ro*******@st2x.net says...
On Sun, 21 Mar 2004 at 01:15 GMT, Sam Snead <sa******@sammy.com> wrote:
Hey, I've been having some trouble debuggin this...I keep getting 500
errors. Would some kind soul be willing to help me?

#!/usr/bin/local/perl


use strict;
use warnings;

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

<some code snipped>
else
{

print <<EndOfHTML;
<html><head><title>Test Page</title></head>
<body>
<h2>Select User</h2>
<form action='./logger.cgi' method=post>
<input type=hidden name=submitted value='yes'>
<select name='userid'>

EndOfHTML

. . . . ^^^^^^^^^
Hey! this is not what you said that your here document would end
with. Either move this marker to the left, or change your print
statement as follows:

print <<' EndOfHTML';

I guess that this will cure most of your problems...

Oh, thank you very much!

Jul 19 '05 #3

"Sam Snead" <sa******@sammy.com> :
Hey, I've been having some trouble debuggin this...I keep getting 500
errors. Would some kind soul be willing to help me? ... if ($FORM{'subitted'} eq 'yes' )
showstats();
else
{


must be:

if ($FORM{'subitted'} eq 'yes' )
{
showstats();
}
else
{

--
Grygory Tertychny
Jul 19 '05 #4
In article <c3**********@news.kiev.sovam.com>, mi***@svitonline.com
says...

"Sam Snead" <sa******@sammy.com> :
Hey, I've been having some trouble debuggin this...I keep getting 500
errors. Would some kind soul be willing to help me?

...
if ($FORM{'subitted'} eq 'yes' )
showstats();
else
{


must be:

if ($FORM{'subitted'} eq 'yes' )
{
showstats();
}
else
{

Thanks, I thought that it would work like C where you don't need braces
for one line, but I was wrong.

Trey
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

23 posts views Thread by ian justice | last post: by
10 posts views Thread by Ray Stevens | last post: by
7 posts views Thread by Swinky | last post: by
41 posts views Thread by Miroslaw Makowiecki | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.