crmpicco
06-20-2006, 10:10 AM
I have this script that is supposed to count access requests. However, it is giving me an error on line 3 ($logpath = count.html).
Code:
!#C:/Perl/bin/perl.exe
$logpath = count.html;
# where access data is kept
$visible = 1;
# show counter or not?
$pad = 5;
# number of digits for your counter
# below is the main processing
open (LOG, "$logpath");
@data = <LOG>;
close(LOG);
# keep following (#7) on 1 line...do no wrap
$url = "<tr><td align=\"right\"><a href=\"$ENV{'DOCUMENT_URI'}\">
$ENV{'DOCUMENT_URI'}</a>:</td>";
$count = 0;
$pad = "%.$pad"."d";
open (LOG, ">$logpath");
foreach $line(@data)
{
if ($line =~ /$url/)
{
$line =~ /<td>(.*)<\/td>/;
$count = $1;
$count++;
$count = sprintf($pad, $count);
print LOG "$url<td>$count</td></tr>\n";
}
elsif ($count == 0 && substr($line,0,8) eq "</table>")
{
$count++;
$count = sprintf($pad, $count);
print LOG "$url<td>$count</td></tr>\n";
print LOG "$line";
}
else
{
print LOG "$line";
}
}
close(LOG);
if ($visible)
{
print "Content-type: text/html\n\n";
print "$count";
}
My error is:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
Can't modify not in scalar assignment at c:\inetpub\wwwroot\picco\accesscounter.pl line 3, near "html;"
Execution of c:\inetpub\wwwroot\picco\accesscounter.pl aborted due to compilation errors.
Cant see what the problem is.....
Picco
Code:
!#C:/Perl/bin/perl.exe
$logpath = count.html;
# where access data is kept
$visible = 1;
# show counter or not?
$pad = 5;
# number of digits for your counter
# below is the main processing
open (LOG, "$logpath");
@data = <LOG>;
close(LOG);
# keep following (#7) on 1 line...do no wrap
$url = "<tr><td align=\"right\"><a href=\"$ENV{'DOCUMENT_URI'}\">
$ENV{'DOCUMENT_URI'}</a>:</td>";
$count = 0;
$pad = "%.$pad"."d";
open (LOG, ">$logpath");
foreach $line(@data)
{
if ($line =~ /$url/)
{
$line =~ /<td>(.*)<\/td>/;
$count = $1;
$count++;
$count = sprintf($pad, $count);
print LOG "$url<td>$count</td></tr>\n";
}
elsif ($count == 0 && substr($line,0,8) eq "</table>")
{
$count++;
$count = sprintf($pad, $count);
print LOG "$url<td>$count</td></tr>\n";
print LOG "$line";
}
else
{
print LOG "$line";
}
}
close(LOG);
if ($visible)
{
print "Content-type: text/html\n\n";
print "$count";
}
My error is:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
Can't modify not in scalar assignment at c:\inetpub\wwwroot\picco\accesscounter.pl line 3, near "html;"
Execution of c:\inetpub\wwwroot\picco\accesscounter.pl aborted due to compilation errors.
Cant see what the problem is.....
Picco