I agree with both Arguile and Boldra in that your question is slightly confusing.

It appears that what you are trying to do is to redirect to another CGI script ('test.cgi') from your script, of which you've presented a fragment. To do this using CGI.pm, you merely have to:

print $q->redirect($refreshUrl);

This sends an HTTP header which has the same effect as putting the following line into the header of an HTML page (hence the name, "HTTP-EQUIV"):

<META HTTP-EQUIV="Refresh" CONTENT="$refreshTime; URL=$refreshUrl">

Your script fragment does precisely the same thing in its last line (which prints the Location: header). In fact, you could get rid of all the other print statements to the same effect.

What's confusing is the relationship between $refreshFile and $refreshUrl. If you meant $refreshUrl to refer to the same file, the one you are creating on the fly, your file would be redirecting to itself in an endless loop.

BTW, the URL in the <SCRIPT> tag (src='http://www.test.com/cgi-bin/test.cgi') should refer to a javascript file, e.g., 'something.js', NOT to a perl script (unless that perl script is a CGI program that writes pure javascript code to its standard output).

Any code between the <SCRIPT> and </SCRIPT> tags ought to be javascript as well.

In either case, the javascript code executes at the BROWSER, not on the server.

dmm


You can give a man a fish and feed him for a day ...
Or, you can teach him to fish and feed him for a lifetime

In reply to Re: Inserting CGI code in script tag by dmmiller2k
in thread Inserting CGI code in script tag 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.