On 4/27/06 10:19 PM, "Mary Anderson" <[EMAIL PROTECTED]> wrote:
>
>
>
>
> Hi,
> I have a cgi program that pulls data out of a database and stores it in
> an array ref. I would like to display this data one row at a time.
> Unfortunately I am having difficulty getting the current index to persist
> from one page to another. I could do this with a hidden field. But I also
> have difficulty getting the array ref to persist once the submit button is
> pushed.
> The general scenario is this. I have a function which sets a value of
> x. I would like to have that
> value of x available on the next call to the function. (Like its supposed
> to be a static variable.)
>
> Here is what I tried:
>
> our %x
>
> sub fu{
> my ($bar) = @_;
> our %x;
> if ($bar){
> $x{'ABC'} = 0
> }
> else{
> $x{'ABC'} = $x{'ABC'} + 1;
> }
> print "Value = $x{'ABC'}", hr;
>
> fu(1);
> <push submit button>
> fu(0);
>
> gives
> Value = 0
> Value =
> }
> How should I be doing this?
Variables in CGI cannot be maintained between pages. You have to redo your
database query for every page (or cache it on disk somewhere--but that is
going to be more complicate) and you are right about needing to use a hidden
field (or a cookie) to pass your index between pages.
Sean
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>