Is it always the same number of digits? E.g. 6?

Your HTML could look something like:

<IMG SRC="digit.pl?position=5" ><IMG SRC="digit.pl?position=4" ><IMG SRC="digit.pl?position=3" ><IMG SRC="digit.pl?position=2" ><IMG SRC="digit.pl?position=1" ><IMG SRC="digit.pl?position=0"

The > is at the beginning of the next line to prevent some browsers (e.g. Netscape) to insert whitespace between one digit and another.

Now all you have to do is:

For example if you dynamically generate the page, you could have something like:

<IMG SRC="digit.pl?position=5&session=foobar-id" ><IMG SRC="digit.pl?position=4&session=foobar-id" ><IMG SRC="digit.pl?position=3&session=foobar-id" ><IMG SRC="digit.pl?position=2&session=foobar-id" ><IMG SRC="digit.pl?position=1&session=foobar-id" ><IMG SRC="digit.pl?position=0&session=foobar-id"
or even (which is text browser friendly):
<IMG SRC="digit.pl?digit=0" ALT=0 ><IMG SRC="digit.pl?digit=0" ALT=0 ><IMG SRC="digit.pl?digit=1" ALT=1 ><IMG SRC="digit.pl?digit=9" ALT=9 ><IMG SRC="digit.pl?digit=7" ALT=7 ><IMG SRC="digit.pl?digit=3" ALT=3

Other possibilities include cookies.

This method makes it easy to glue together many images in your HTML, if it is dynamically generated, for example the result of a CGI. Otherwise digit.pl has to go through a god deal of work (presumably) to generate an progressive number for each visitor, which does not mean increase the counter every time digit.pl is called, not even every six times digit.pl is called, because basically you have no idea of what could happen.

So you may want to consider this solution if you dynamically generate your HTML, otherwise you require much more effort to make digit.pl work reliably for each digit and for each session/user.

-- TMTOWTDI


In reply to Re: Counter problem by trantor
in thread Counter problem 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.