Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
PerlMonks idiosyncrasy?

by dusk (Friar)
on May 30, 2001 at 07:21 UTC ( #84157=perlquestion: print w/replies, xml ) Need Help??

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

Fellow monks,

I encountered a strange problem while writing a CGI script for a site I'm developing. Here's the scoop:

print header, start_html (-title => 'Welcome to!', Link ({-rel => 'stylesheet', type => 'text/css', href => + 'style.css'}), base ({-href => ''}), ), body ({-vlink => 'black'})

The preceeding causes the proceeding:

Content-Type: text/html; charset=ISO-8859-1 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" ""> <html xmlns="" lang="en-US"><head><title>T +he POSIX Network</title> </head><body <link href="style.css" rel="stylesheet" type="text/css" / +>="&lt;base href=&quot; +uot; /&gt;"><body vlink="black" />,

As you can see, it appears as the opening body tag is not being closed, and the tag delimters are converted into their counter-equivalent (whatever that means) [&lt;, &gt;, &quot;]

Any explanation of what is going on will be helpful.


Replies are listed 'Best First'.
Re: idiosyncrasy?
by Trimbach (Curate) on May 30, 2001 at 07:56 UTC
    The "base" and "vlink" tags both belong in the "start_html" method when you're using There is no "body" function per se in, so by typing it the module is assuming you know what you're doing and pretends it's a valid tag. Your "body" function doesn't "enclose" anything, so makes the perfectly valid guess that "body" is a self-closing tag like "break " and puts the closing slash within the tag per XHTML 1.0 guidelines. You're getting similar problems with "base" which should also be an attribute of start_html, and not it's own function/method.

    Try this instead: (untested)

    print header, start_html (-title => 'Welcome to!', Link ({-rel => 'stylesheet', type => 'text/css', href => + 'style.css'}), base => '', vlink => "Black");
    For more info check out the "start_html" docs in the POD.

    Gary Blackburn
    Trained Killer

Re: idiosyncrasy?
by Zaxo (Archbishop) on May 30, 2001 at 09:35 UTC
    <it>start_html({ ...</it>
    -head=>[Link({{-rel => 'stylesheet', type => 'text/css', href => 'style.css'}),],

    To distribute the -head key the usual ref convention of applies

    After Compline

      Changing   body ({-vlink => 'black'}) to   body ({-vlink => 'black'}, '') will solve one of the remaining problems.
Re: idiosyncrasy?
by hackmare (Pilgrim) on May 30, 2001 at 16:49 UTC
    You have a misplaced body tag which is nonsensical in the start_html context Try this program (note that it doesnt send xhtml).

    (Tested on solaris with perl5.0503)

    use CGI;
    use strict;
    my $p = new CGI;
    print $p->header;
    print $p->start_html(-title=>'Welcome to!',
                         -base=>{href => ''},
                         -meta=>{'keywords'=>'pharoah secret mummy',
                                   'copyright'=>'Hackmarish Things Happening'},
    		     -vlink => 'black');
    print $p->p('Is this what you want?');
    print $p->end_html;

    <HTML><HEAD><TITLE>Welcome to!</TITLE>
    <BASE HREF="http://localhost/">
    <META NAME="keywords" CONTENT="pharoah secret mummy">
    <META NAME="copyright" CONTENT="Hackmarish Things Happening">
    <LINK REL="stylesheet" HREF="/styles/style1.css">
    </HEAD><BODY BGCOLOR="blue" VLINK="black"><P>Is this what you want?</P></BODY></HTML>

    This code was adapted from the html POD

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://84157]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2023-09-28 07:34 GMT
Find Nodes?
    Voting Booth?

    No recent polls found