i love perl but i wish to rant a bit.
my script worked perfectly until i changed something somewhere else.
the problem seems to be that perl does things behind your back like changing numbers to strings and back again instead of generating an error message.
like microsoft windows very nice when it works but very difficult to fix when it does not.
this code is a subroutine from a hit counter script which increments the counter in the file when you say Yes but otherwise not. it then goes on to generate a bmp file which contains the graphic of the hit counter.
after many days and nights and much pondering i added the line sprintf and all was well. sprintf is what is happening behind your back all the time so why not now?
please ignore the flock. it is supposed to make it multi-user. i don't know if it does or not.
thank you for reading this.
sub opennumfile{
open(COUNT,$count) or die ("Can't open $count: $!");
flock(COUNT, 1); #shared lock for reading
$c = <COUNT> ;
close(COUNT) or die ("Can't close $count: $!");
if ($count =~ /\n$/) {chomp($c);}
if (!defined($y = param('update'))){ $y = "Yes"; }
if (uc($y) eq "YES"){
$c++;
open(COUNTER,">$count") or die ("Can't open $count: $!");
flock(COUNTER, 2); #exclusive lock for writing
print COUNTER "$c\n$somethingfile\n"; # path to the calling web page
close(COUNTER) or die ("Can't close $count: $!");
}
$c = sprintf("%d", $c); # essential line but only if $y ne "YES"
$nim = $r = length($c);
while ($r > 0) {
$char[$r] = chop($c);
$r--;
}
}