Mark Tarver wrote:
Hi,
I have a very simple request.
I want to know how many people click on a link. So what I want is a
piece of Perl that writes this to a file. It can just be a tally mark
like
! placed in the file.
I cannot place anything on the target page because it does not belong
to me. Code gratefully received.
Mark
Mark,
Do you have to use Perl here for a particular reason ? It would
probably be easiest to set something up in JavaScript. Perhaps an event
listener that calls a method that keeps track of these clicks -- or
perhaps that calls a URL where your Perl script lives to count clicks
then sends the user to the destination.
If that can work for you a simple script that opens up a log counter
file, reads in that value and increments it by one each time should suffice.
my $counter_log = 'counter.log';
open COUNT, "<$counter_log" or die ("Could not open!");
$num_hits = <COUNT>;
close COUNT;
$num_hits++;
open COUNT, ">$counter_log" or die ("Could not open file for writing!");
print COUNT $num_hits;
close COUNT;
-Terry Grant
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/