http://qs321.pair.com?node_id=102607

jrbush82 has asked for the wisdom of the Perl Monks concerning the following question:

hello, today is my first day with perl... I've setup plenty of "free" perl scripts. Anybody have any idea on what could be wrong with this?

#!/usr/bin/perl #begins for loop of READCOUNTER so that it has to lock file before rea +ding READCOUNTER: for ($i=0; defined($i); $i++){ #opens counter data file open(COUNTERDAT,"./counter.dat"); #locks file, and if can't, goes back to READCOUNTER to try again flock COUNTERDAT, 1 or next READCOUNTER; #puts first line of counter data file in first array (0) called counte +rdat while (<COUNTERDAT>){ push @counterdat, $_; } #closes counter data file close COUNTERDAT; #ends for loop of READCOUNTER last READCOUNTER; } #sets previous number in counter.dat to one higher $pnum = $counterdat[0]; $pnum++; #begins loop of WRITECOUNTER so that it has to lock file before writin +g WRITECOUNTER: for ($i=0; defined($i); $i++){ #opens counter data file again open(COUNTERDAT,">./counter.dat"); #locks file, and if can't, goes back to WRITECOUNTER flock COUNTERDAT, 2 or next WRITECOUNTER; #writes new number to counter data file print COUNTERDAT "$pnum"; #closes counter data file close COUNTERDAT; #ends loop for WRITECOUNTER last WRITECOUNTER; } #begins for loop of READCOUNTER2 so that it has to lock file before re +ading READCOUNTER2: for ($i=0; defined($i); $i++){ #opens counter data file open(COUNTERDAT2,"./counter.dat"); #locks file, and if can't, goes back to READCOUNTER to try again flock COUNTERDAT2, 1 or next READCOUNTER2; #puts first line of counter data file in first array (0) called counte +rdat2 while (<COUNTERDAT2>){ push @counterdat2, $_; } #closes counter data file close COUNTERDAT; #ends for loop of READCOUNTER2 last READCOUNTER2; } print<<HTMLEND; content type; text/html $counterdat2[0] HTMLEND
and I am using this for my include in a .shtml file
<!--#include virtual="cgi-bin/counter/counter.cgi" -->
Thanks,
jrbush82

Edit ar0n 2001-08-06 -- Added <code> tags.