As others have said, the problem is that when the user visits the page again, your script is run from scratch, and doesn't have any information about what happened last time it ran.

The most common way to deal with this is with sessions. When a user runs your script for the first time, generate some kind of unique identifier for them. Either store that as a hidden CGI parameter, put it into the URL as a parameter or path component, or stick it in a cookie. When your script runs again, retreive that token; you can use it to track the same user between multiple runs of your script, and do things like store information about previous runs in a file named for the session key.

There are lots of modules to do this. Search CPAN for Session for a few.


In reply to Re: Accumulate results from multiple CGI calls for browser viewing by sgifford
in thread Accumulate results from multiple CGI calls for browser viewing 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.