Put both files in your cgi-bin.
Set CHMOD scount.pl 755
Set CHMOD counterdata.txt 777

To count hits and show the count on the page, just use an include.
For example:
<!--#include virtual="cgi-bin/scount.pl" -->

To count hits and NOT show anything on the page, use ?noshow=1 at the end of the script.
For example:
<!--#include virtual="cgi-bin/scount.pl?noshow=1" -->
