[Fri Jul 07 20:10:28 2006] [error] [client 127.0.0.1] Bareword found where operator expected at C:/Program Files/Apache Group/Apache2/cgi-bin/template1.pl line 13, near "print "Content-Type: text/html" [Fri Jul 07 20:10:28 2006] [error] [client 127.0.0.1] (Might be a runaway multi-line // string starting on line 2) [Fri Jul 07 20:10:28 2006] [error] [client 127.0.0.1] (Do you need to predeclare print?) [Fri Jul 07 20:10:28 2006] [error] [client 127.0.0.1] Unquoted string "html" may clash with future reserved word at C:/Program Files/Apache Group/Apache2/cgi-bin/template1.pl line 13. [Fri Jul 07 20:10:28 2006] [error] [client 127.0.0.1] syntax error at C:/Program Files/Apache Group/Apache2/cgi-bin/template1.pl line 13, near "print "Content-Type: text/html" [Fri Jul 07 20:10:28 2006] [error] [client 127.0.0.1] Execution of C:/Program Files/Apache Group/Apache2/cgi-bin/template1.pl aborted due to compilation errors. #### #template1.tmpl Test Template My Home Directory is

My Path is set to #### #!/bin/perl.exe -w use lib '/site/lib'; use HTML::Template; # open the html template my $template = HTML::Template->new(filename => 'template1.tmpl'); # fill in some parameters $template->param(HOME => $ENV{HOME}); $template->param(PATH => $ENV{PATH}); # send the obligatory Content-Type and print the template output print "Content-Type: text/html\n\n", $template->output; #### #!bin/perl.exe -w #This CGI script extracts weather information from the Australian Bureau of #retrieve url, and split into segments on double new-lines, which seems to be the divider #between each Station section use warnings; #use strict; use LWP::Simple; $file = get "http://www.bom.gov.au/cgi-bin/wrap_fwo.pl?IDN10177.txt"; @segments = split(/\n{2}/, $file); #Html file necessities print "Content-type: text/html\n\n"; print < Weather to the minute!

SLP802

EOM foreach (@segments) { if ($_ =~ /IDN\w/) { $heading = "$&$'"; $heading =~ s/(\n)/
/g; print "

$heading

"; } } print <
Region Name Av Min Temp(°C)Av Max Temp(°C)Av Rainfall(mm) EOM foreach $segments(@segments) { if ($segments =~ /Station/) { $region = ®ionname($segments); $min = &mintemp($segments); $max = &maxtemp($segments); $rain = &rainfall($segments); print "$region$min$max$rain"; } } print "\n"; sub regionname { local $seg = $_[0]; local $region; local @words = split(/\n/,$seg); $region = $words[0]; return $region; } sub mintemp { local $seg = $_[0]; local ($min, $size, $line, $numregion); local $num = 0; local $sum = 0; local @words = split(/\n/,$seg); foreach (@words) { if ($_ =~ /^([A-Z]{1}[a-z]{1})/) { $line = $_; chomp($line); $size = length($line); $numregion = substr($line, ($size - 19), 5); if ($numregion =~ /(-?[0-9]+)/) { $sum = $sum + $&; $num++; } } } if ($num == 0) { $min = 0; } else { $min = $sum/$num; if ($min =~ /(-?[0-9]+\.[0-9]{2})/) { #the average is intended $min = $&; #to be rounded off here, } #but it is merely chopped } #due to limited know-how #on perl rounding. return $min; } sub maxtemp { local $seg = $_[0]; local ($max, $size, $line, $numregion); local $num = 0; local $sum = 0; local @words = split(/\n/,$seg); foreach (@words) { if ($_ =~ /^([A-Z]{1}[a-z]{1})/) { $line = $_; chomp($line); $size = length($line); $numregion = substr($line, ($size - 12), 5); if ($numregion =~ /(-?[0-9]+)/) { $sum = $sum + $&; $num++; } } } if ($num == 0) { $max = 0; } else { $max = $sum/$num; if ($max =~ /([0-9]+\.[0-9]{2})/) { $max = $&; } } return $max; } sub rainfall { local $seg = $_[0]; local ($rain, $size, $line, $lastchar, $numregion); local $num = 0; local $sum = 0; local @words = split(/\n/,$seg); foreach (@words) { if ($_ =~ /^([A-Z]{1}[a-z]{1})/) { $line = $_; chomp($line); $size = length($line); $lastchar = substr($line, ($size - 1), 1); if (($lastchar ne " ") && ($lastchar ne "-")){ $line =~ s/(tr)/0/gi; $numregion = substr($line, ($size - 5), 5); $numregion =~ /\S+/; $sum = $sum + $&; $num++; } } } if ($num == 0) { $rain = 0; } else { $rain = $sum/$num; if ($rain =~ /([0-9]+\.[0-9]{2})/) { $rain = $&; } } return $rain; } print< EOM