My CGI code needs to do this:

  1. Retrieve parameters from a flat file
  2. Insert them as values into an HTML form
  3. Allow the user to modify the values in the form
  4. Preview the modified values
  5. Save the modified values again into a flat file

So there are two sources for name/value pairs: the flat file and the HTML posts. These two sources have the same variables consistently throughout the application. I created two CGI objects, one for each source. And in my naiveté called them both $q, to save myself having to figure out how to pass the variables from one object into another inside of the code. Samples:

Getting the name/value pairs from the HTML form post:

$q = new CGI; { my $q = shift; my %query_hash; foreach ( $q->param() ) { $query_hash{$_} = $q->param($_); } return %query_hash; }

Getting the name/value pairs from the flat file:

{ open (REVIEW, "<review.txt") or die "can't open review.txt!"; $q = new CGI("REVIEW"); close (REVIEW); }

Saving the name/value pairs to the flat file:   $q->save("NEWREVIEW");

I ran this by TGI and he's not sure how kosher it is to have 2 CGI objects with the same name, and he's not sure if using $q->save is a good idea. He told me to put the question before y'all.

Any advice? I'll take anything you can give-

Thanks,

LadyD


In reply to Multiple CGI Objects w/ Same Name by LadyD

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.