: here is the program in full so you may verify i did it correctly (i'm =
: sure there was a shorter way, but right now i'm just trying to get the =
: darn thing to work!!!) But now an error of an uninitialize value in 46 =
: &51 occurs and I don't know what to do..please assist? I marked them =
: with a comment like this "####### use of uninitialize value". Also an =
: error "Arguement "" isn't numeric in eq at line 58" also marked as =
: above.
These warnings apparently come from the fact that counter.txt either
doesn't exist yet, can't be opened, or contains something that is not a
number. Before running the program, try creating the file counter.txt
containing just a 0. When I tried your script this way, the warnings
went away.
A couple of tips:
When you try to open a file, check to make sure you were successful.
For example:
open(NUMBER,"$counterfile") or die "Can't open $counterfile: $!";
$number=<NUMBER>;
close(NUMBER);
You might actually want to do something friendlier than "die", but this
is a start.
Also,
open(IMAGE,"<$imagereturn");
print <IMAGE>;
close(IMAGE);
is not a very efficient way to send back binary data like images. The
problem is that the image will first be broken into a list of "lines"-
which can take up a lot of memory- and then the list will be printed.
It's probably not a big deal for small things like counter images, but
I learned my lesson trying to send .5-megabyte binary files this way
and got "out of memory" errors. It's more efficient to read() the file
and print:
open IMAGE, $imagereturn or die "Can't open $imagereturn: $!";
while ( read(IMAGE, $_, 100_000) ) { print STDOUT; }
close IMAGE;
This will read the image in 100kb chunks and print them to stdout, one
at a time.
Finally, may I ask why you wrote your own CGI parser? CGI.pm can take care
of this for you, handles either GET or POST, will do the unescaping, etc.
-- tdk