My Perl cgi script "ip2loc.pl" is called once from an x.shtml with an
<!--#exec ...-->.
Unfortunately it executes twice:

Ip2loc.pl creates an HTML form with cgi.pm, and "prints" it to the browser. When ip2loc.pl is initially executed, it creates the form properly but does not wait for the Submit to be pushed before going ahead and processing the (null) output from the form. Eventually, when the form is filled out and the Submit button IS pushed, ip2loc.pl executes in its entirety (from its beginning) a second time. This second time the data is present and duly processed by ip2loc.pl.

How do I get ip2loc.pl to pause after creating the form until the Submit button is pushed?

[Possibly involved: my script is initiated from the middle of an HTML page (which of course already has a header) which forms a boilerplate style frame for my script's Form. My script issues a header too (implicit action of the start_html() call - see attachment below). Perhaps a single HTML page cannot have two headers. If this is the case, my question becomes: how would I prevent CGI.pm from issuing a header for the Form in question?]


Thank you,
Peter Schwenn
p.s. The code in my script ip2loc.pl which creates the HTML Form is:
... use CGI ':standard'; .... print start_html('Get Email Address'), h3('Input the email address to receive the Download Link:'), startform("GET"), "Email Address : ", textfield("clientEmail",""), " ", submit("Submit"),"<br/><br/ >", endform(), ; ...

20080718 Janitored by Corion: Fixed square brackets, as per Writeup Formatting Tips


In reply to Cgi script executing twice by schwenn

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.