CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Runtime Errors

 



ee91gg
Deleted

May 12, 2000, 9:47 PM

Post #1 of 4 (494 views)
Runtime Errors Can't Post

Hi everyone,

I don't know if anyone can help me, but i'm getting runtime errors in places that don't seem to have any errors (as far as i can see). I get;
****************************************

syntax error at /a/fserva/fserva/fserva27/eemeng99/ee91gg/no-wave-cgi/log.cgi line 117, near "print" syntax error at /a/fserva/fserva/fserva27/eemeng99/ee91gg/no-wave-cgi/log.cgi line 131, near "else"
Execution of /a/fserva/fserva/fserva27/eemeng99/ee91gg/no-wave-cgi/log.cgi aborted due to compilation errors.

**********************
on this peice of code;
**********************

sub write_data {
if (-1 < $yday && $yday < 150){
if ($t == 0){$t = 1;$x = $x + 1;}
$this_day = ($x * 365) + ($last_day - $yday);}
if (149 < $yday && $yday < 366){
$t = 0;
$this_day = $x*365 + ($last_day - $yday);}

if ($numt != 0){$percentn = ($numn / $numt) * 100;}
else{$percentn = 0;}
if ($numt != 0){$percenti = ($numi / $numt) * 100;}
else{$percenti = 0;}
if ($numt != 0){$percento = ($numo / $numt) * 100;}
else{$percento = 0;}
if ($this_day != 0){$num_per_day = $numt / $this_day;}
else{$num_per_day = 0;}

open(DATA,">$basedir/$mesgdir/$datafile")
if ($reset == 1){
print DATA "\%user_times = (\n";
# line 117
print DATA ");\n\n";
print DATA "\%user_last = (\n";
print DATA ");\n\n";
print DATA "\$numn = 0;\n\n";
print DATA "\$numi = 0;\n\n";
print DATA "\$numo = 0;\n\n";
print DATA "\$numt = 0;\n\n";
print DATA "\$x = 0;\n\n";
print DATA "\$t = 1;\n\n";
print DATA "\$this_day = 0;\n\n";
print DATA "\$last_day = $yday;\n\n";
print DATA "\$launch_date = '$true_time at $true_date';\n\n";
print DATA "1;\n";
close(DATA);}
#line 131
else{
print DATA "# Date & Time Launched / last reset\n";
print DATA "\$launch_date = '$launch_date';\n\n";
print DATA "# Average number of hits per day\n";
print DATA "\$num_per_day = $num_per_day;\n\n";
print DATA "# Total number of hits\n";
print DATA "\$numt = $numt;\n\n";
print DATA "# Number of days since launch (excluding leap-years)\n";
print DATA "\$this_day = $this_day;\n\n";
print DATA "# Last day accessed\n";
print DATA "\$last_day = $yday;\n\n";
print DATA "# Percent netscape 4.0+ users\n";
print DATA "\$percentn = $percentn;\n\n";
print DATA "# Percent i.e. 4.0+ users\n";
print DATA "\$percenti = $percenti;\n\n";
etc...

****************************************
What's up? Am i going mad or is the code wrong?


Cure
User

May 14, 2000, 9:12 AM

Post #2 of 4 (494 views)
Re: Runtime Errors [In reply to] Can't Post

Hi

Here, I fixed the code for you-->

sub write_data {
if (-1 < $yday && $yday < 150){
if ($t == 0){$t = 1;$x = $x + 1;}
$this_day = ($x * 365) + ($last_day - $yday);}
if (149 < $yday && $yday < 366){
$t = 0;
$this_day = $x*365 + ($last_day - $yday);}

if ($numt != 0){$percentn = ($numn / $numt) * 100;}
else{$percentn = 0;}
if ($numt != 0){$percenti = ($numi / $numt) * 100;}
else{$percenti = 0;}
if ($numt != 0){$percento = ($numo / $numt) * 100;}
else{$percento = 0;}
if ($this_day != 0){$num_per_day = $numt / $this_day;}
else{$num_per_day = 0;}

open(DATA,">$basedir/$mesgdir/$datafile") or die $!;
if ($reset == 1){
print DATA "\%user_times = (\n";

print DATA ");\n\n";
print DATA "\%user_last = (\n";
print DATA ");\n\n";
print DATA "\$numn = 0;\n\n";
print DATA "\$numi = 0;\n\n";
print DATA "\$numo = 0;\n\n";
print DATA "\$numt = 0;\n\n";
print DATA "\$x = 0;\n\n";
print DATA "\$t = 1;\n\n";
print DATA "\$this_day = 0;\n\n";
print DATA "\$last_day = $yday;\n\n";
print DATA "\$launch_date = '$true_time at $true_date';\n\n";
print DATA "1;\n";
close(DATA);}

else{
print DATA "# Date & Time Launched / last reset\n";
print DATA "\$launch_date = '$launch_date';\n\n";
print DATA "# Average number of hits per day\n";
print DATA "\$num_per_day = $num_per_day;\n\n";
print DATA "# Total number of hits\n";
print DATA "\$numt = $numt;\n\n";
print DATA "# Number of days since launch (excluding leap-years)\n";
print DATA "\$this_day = $this_day;\n\n";
print DATA "# Last day accessed\n";
print DATA "\$last_day = $yday;\n\n";
print DATA "# Percent netscape 4.0+ users\n";
print DATA "\$percentn = $percentn;\n\n";
print DATA "# Percent i.e. 4.0+ users\n";
print DATA "\$percenti = $percenti;\n\n";
}
}

Cure


ee91gg
Deleted

May 16, 2000, 6:44 AM

Post #3 of 4 (494 views)
Re: Runtime Errors [In reply to] Can't Post

Thanks again Cure, you really are a star!


Cure
User

May 16, 2000, 8:00 AM

Post #4 of 4 (494 views)
Re: Runtime Errors [In reply to] Can't Post

Your Welcome


Cure

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives