Reverend Phil has asked for the wisdom of the Perl Monks concerning the following question:

Hi folks. I'm new to CGI, and I'm trying to get a page refresh after 3 seconds. From the CGI.pm docs, it looks like I should be able to do an http-equiv tag like so:
start_html(-title=>"Title", -author=>'a@b.c', -head=>meta({-http_equiv=>'Refresh', -content=>'3;url=http://internalserver/phil/2.pl'}), -BGCOLOR=>'tan');
Unfortunately, this produces:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <HTML><HEAD><TITLE>Title</TITLE> <LINK REV=MADE HREF="mailto:a%40b.c"> </HEAD><BODY BGCOLOR="tan">
It's ignoring my META tag, and I can't figure it out.
The html that should be generated is something akin to:
<META HTTP-EQUIV="Refresh" CONTENT = "seconds;url">
Alternatively, if there's a way to use the start_html method to create your header, yet add a tag to it (like above) as a scalar, that would be sweet also.
Thanks in advance.
-rev

Replies are listed 'Best First'.
Re: CGI: Having Trouble with HTTP-EQUIV
by wardk (Deacon) on Jan 15, 2001 at 22:51 UTC
    use CGI qw/:standard/; my $q = new CGI(); print $q->header; print $q->start_html(-head=>meta({-http_equiv=>'Refresh', -content=>'3,http://foo.com/'}));

    produces:

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <HTML><HEAD><TITLE>Untitled Document</TITLE> <META CONTENT="3,http://foo.com/" HTTP-EQUIV="Refresh"> </HEAD><BODY>
Re: CGI: Having Trouble with HTTP-EQUIV
by ichimunki (Priest) on Jan 15, 2001 at 22:49 UTC

    WardK's answer is better, but for informational purposes...

    What does your use CGI statement look like? That could be having an effect. Also, have you tried putting the refresh info into the header() function for the page? Technically the <meta http-equiv...> mimics information that would normally be in the HTTP header, which means that you would be better off putting it there directly if possible (note). The form may change from how you have it (and I think it would be

    header( { -Refresh => "3;url=http://www.untestedsolution.com/" } ).
    )

Re: CGI: Having Trouble with HTTP-EQUIV
by repson (Chaplain) on Jan 16, 2001 at 10:21 UTC
    Not meaning an insult, but you are doing this backward.... the meta http-equiv tag is used to tell your webserver of extra http headers to include in your responce. A standard http responce loosely looks a bit like this.
    200 OK Content-type: text/html Refresh: 0 Expires: now <html><head><meta http-equiv="refresh" content="0"></head> <body>document</body></html>
    So instead of generating a meta http-equiv tag you should be generating the header yourself in your header call, something like:
    print header( -type => 'text/html', -refresh => '0' );
Re: CGI: Having Trouble with HTTP-EQUIV
by little (Curate) on Jan 16, 2001 at 14:39 UTC
    Sorry, I dunno which version of cgi.pm you are using, but http-equiv is explicitely not supported, cause Lincoln said: you shall use the header to send such kind o information to the browser. So you might consider using a redirection header sent to the browser.
    Have a nice day
    All decision is left to your taste
Re: CGI: Having Trouble with HTTP-EQUIV
by Reverend Phil (Pilgrim) on Jan 15, 2001 at 23:12 UTC
    Ahhh.. show me one error, and I'll find 10 more. I see where my problems are. Head not on straight enough. Thanks for the help.
    I wish someone else here was enlightened so that I could bounce the language of the gods off of them and find 'stupid errors' before scouring websites and seeking wisdom from the collective conscious.
    -rev