in reply to Saving state in cgi.pm question

You appear to have a either a closure or global variables on $query, $file, and %list. Under various conditions you may get unexpected results. It is better practice to pass values to subroutines as arguments.

sub printboxes { my ($query, $file, %list) = @_; # ... open FH, '> ' . $file or die $!; $query->save(FH) or die $!; close FH or die $!; }
I added some error checking on the save operations, so you get better information if something there is the problem.

Update: The data you get saved suggests that $query does not have any data in it. Could be the kind of unexpected behavior I mentioned. Or do your test runs neglect to provide data?

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: Saving state in cgi.pm question
by Popcorn Dave (Abbot) on Nov 25, 2002 at 07:07 UTC
    Thanks for the response, but I'm still having the same problem. I can write the file fine, but all it contains is one '=' sign and that's it. I have tried checking off some of the boxes ( saving the state *should* be storing my selections shouldn't it? ) but I'm not getting any actual data saved.

    Any ideas in that direction?

    Unless I am misunderstanding how the saving of the state works, I can't see a need to process the data if you can save it. Also, does the save happen after the submit button is pushed?

    Thanks!

    There is no emoticon for what I'm feeling now.