I think there is a little confusion here. It is not useful to pass query arguments to a cgi-bin script this way, because you will get the literal string $document.

Here is a complete solution:
Put this line in every page that you want to be counted:

<!--#include virtual="/cgi-bin/counter.pl" -->

Those pages shuold have extensions .shtml

The code for counter.pl is:

#!/usr/bin/perl use Fcntl qw(:DEFAULT :flock); use Digest::MD5 qw( md5_base64 ); use strict; use vars qw( $referer $counter_file $ofh $num ); $referer = $ENV{DOCUMENT_URI}; $counter_file = "/home/httpd/(your_site)/var/counter/". md5_base64($re +ferer); sysopen(FH, $counter_file, O_RDWR | O_CREAT) or die "can't open numfil +e: $!"; $ofh = select(FH); $| = 1; select ($ofh); flock(FH, LOCK_EX) or die "can't write-lock numfile: $!"; $num = <FH> || 0; seek(FH, 0, 0) or die "can't rewind numfile : $!"; print FH $num+1, "\n" or die "can't write numfile: $!"; truncate(FH, tell(FH)) or die "can't truncate numfile: $!"; close(FH) or die "can't close numfile: $!"; print "Content-type: text/html\r\n\r\n"; print "Counter for $referer is $num\n";

We can't use HTTP_REFERER because we are not a page, we are a sort of subrequest. The code for the counter is taken from perlopentut.

Hope this clarifies the problem. Ciao, Valerio


In reply to Re: Re^3: SSI pain... by valdez
in thread SSI pain... by Anonymous Monk

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.