Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am getting a missing semicolon error and I'm not sure why. I am certain I have my semicolons in the appropriate places.
I am posting only the subroutine that is giving me problems. Where I'm getting problems is where you see the 6 semicolons in a row. Without those, and the additional semicolon following $thit=0, the program will not compile. With the semicolons in, it does compile. For a point of reference, the line with the semicolons is line 642. I will list my code and then my error message. I'd appreciate any solutions. After the code I will post my error message.
sub sta_data { my $file5 = $cycle."prec_type$prj[$y].txt"; my $pre_wfo="ABQ"; my @wfavg=(0,0,0); my $avg=9999.000; my $cases=99 +99; my @avg; my $mem; my $count=0; my $pod=0; my $far=0; my $misses=0; open FH, "> /ptmp/$USER/wx/$file5" or die $!; $cases=$thit+$tmiss+$twrong; $avg=sprintf("%.4f",$thit/$cases) if $cases ne 0; printf FH ("%-10s","Location"); printf FH ("%8s","CSI"); printf FH ("%8s","Cases\n"); printf FH ("%-10s","Overall"); printf FH ("%8s","$avg"); printf FH ("%8s","$cases\n"); $avg=9999.000; $cases=$east[0]+$east[1]+$east[2]; $avg=sprintf("%.4f",$east[0]/$cases) if $cases ne 0; printf FH ("%-10s","Eastern"); printf FH ("%8s","$avg"); printf FH ("%8s","$cases\n"); $avg=9999.000; $cases=$cent[0]+$cent[1]+$cent[2]; $avg=sprintf("%.4f",$cent[0]/$cases) if $cases ne 0; printf FH ("%-10s","Central"); printf FH ("%8s","$avg"); printf FH ("%8s","$cases\n"); $avg=9999.000; $cases=$sout[0]+$sout[1]+$sout[2]; $avg=sprintf("%.4f",$sout[0]/$cases) if $cases ne 0; printf FH ("%-10s","Southern"); printf FH ("%8s","$avg"); printf FH ("%8s","$cases\n"); $avg=9999.000; $cases=$west[0]+$west[1]+$west[2]; $avg=sprintf("%.4f",$west[0]/$cases) if $cases ne 0; printf FH ("%-10s","Western"); printf FH ("%8s","$avg"); printf FH ("%8s","$cases\n"); $avg=9999.000; $cases=9999; foreach $mem ( sort {$locs{$a}[0] cmp $locs{$b}[0]} keys %locs ) { if (exists $hits{$mem}) { if ($pre_wfo ne $locs{$mem}[0]){ $cases=$wfavg[0]+$wfavg[1]+$wfavg[2]; $avg=sprintf("%.4f",$wfavg[0]/$cases) if $cases ne 0; printf FH ("%-10s","$pre_wfo(WFO)"); printf FH ("%8s","$avg"); printf FH ("%8s","$cases\n"); @wfavg=(0,0,0); $cases=9999; $avg=9999.000; } $pod=$hits{$mem}[0] if ($hits{$mem}[0]); $far=$hits{$mem}[1] if ($hits{$mem}[1]); $misses=$hits{$mem}[2] if ($hits{$mem}[2]); $cases=($pod+$far+$misses); $avg=sprintf("%.4f",$pod/$cases) if $cases ne 0; @wfavg=($wfavg[0]+$pod,$wfavg[1]+$far,$wfavg[2]+$misses); $pre_wfo=$locs{$mem}[0]; } if ($missing eq "yes") { printf FH ("%-10s","$mem"); printf FH ("%8s","$avg"); printf FH ("%8s","$cases\n"); } if ($missing eq "no" and $avg ne 9999) { printf FH ("%-10s","$mem"); printf FH ("%8s","$avg"); printf FH ("%8s","$cases\n"); } undef @avg; $avg=9999.000;$cases=9999; $pod=0;$far=0;$misses=0; } # Handles the last WFO data that can not print in the above loop $cases = $wfavg[0]+$wfavg[1]+$wfavg[2]; $avg = sprintf("%.4f",$wfavg[0]/$cases) if $cases ne 0; printf FH ("%-10s","$pre_wfo(WFO)"); printf FH ("%8s", "$avg"); printf FH ("%8s", "$cases\n"); print FH "\nTotal $thit $tmiss $twrong \ NoWx @no_wx \ Rain @rain \ RaSH @rain_sh \ Driz @driz \ Snow @snow \ SnSH @snow_sh \ IceP @ip \ FzRa @zr \ FzDr @zd \ Thun @ts \ Fog @fog \ FzFg @zfog \ IceF @ifog \ Haze @haze \ Blow @blow \ Smok @smoke \ Volc @va \ ;;;;; $tmiss=0;; $thit=0; $twrong=0; @east=(0,0,0);@cent=(0,0,0);@sout=(0,0,0);@west=(0,0,0); @rain=(0,0,0);@rain_sh=(0,0,0);@driz=(0,0,0);@snow=(0,0,0); @snow_sh=(0,0,0);@ip=(0,0,0);@zd=(0,0,0);@zr=(0,0,0); @ts=(0,0,0);@fog=(0,0,0);@zfog=(0,0,0);@ifog=(0,0,0); @haze=(0,0,0);@blow=(0,0,0);@smoke=(0,0,0);@va=(0,0,0); @bs=(0,0,0);@no_wx=(0,0,0); close FH; undef %hits; $avg=9999.000; $cases=9999; }
The error message:
Semicolon seems to be missing at /scripts/non-codes.plx line 642.
Global symbol "$twron" requires explicit package name at /scripts/non-codes.plx line 643.
syntax error at /scripts/non-codes.plx line 643, near "$twron# line 351g"
Execution of /scripts/non-codes.plx aborted due to compilation errors.
My version of Perl is: This is perl, v5.8.2 built for aix-thread-multi
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Semicolon seems to be missing?
by moritz (Cardinal) on Apr 15, 2011 at 15:00 UTC | |
by kennethk (Abbot) on Apr 15, 2011 at 15:06 UTC | |
by Anonymous Monk on Apr 15, 2011 at 15:10 UTC | |
by kennethk (Abbot) on Apr 15, 2011 at 16:04 UTC | |
|
Re: Semicolon seems to be missing?
by BrowserUk (Patriarch) on Apr 15, 2011 at 15:04 UTC | |
|
Re: Semicolon seems to be missing?
by tospo (Hermit) on Apr 15, 2011 at 15:02 UTC | |
|
Re: Semicolon seems to be missing?
by jffry (Hermit) on Apr 15, 2011 at 15:08 UTC | |
|
Re: Semicolon seems to be missing?
by lamprecht (Friar) on Apr 15, 2011 at 15:04 UTC | |
|
Re: Semicolon seems to be missing?
by Anonymous Monk on Apr 15, 2011 at 15:08 UTC | |
by LanX (Saint) on Apr 15, 2011 at 15:16 UTC |