#!/usr/bin/perl -wT # count.pl use strict; use Fcntl qw(:flock); use Untaint; my $counter = untaint(qr(.*\.dat$), $ARGV[0]); my $silent = 0; my $link = 1; my $link_URL = "http://www.perl.org"; my $SEMAPHORE = $counter . ".lck"; open(S,">$SEMAPHORE") || die "Can't open Semaphore file ($SEMAPHORE): $!"; flock (S, LOCK_EX); if (-e $counter) { open (FILE, $counter) || die "Can't read counter. $!"; my $visits = ; close (FILE); } open (FILE, ">$counter") || die "Cant write to counter. $!"; print FILE ++$visits; close (FILE); close (S); if (!$silent) { if ($link) { print qq($visits); else{ print $visits; } }