oops, I did all this manually, and code was still messed up.. here is the real code that html doesn't mess with...
#!/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

In reply to Re: newbie writing a counter by jrbush82
in thread newbie writing a counter by jrbush82

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.