in reply to How do I create font tags with cgi.pm?
You might want to rethink using CGI.pm for this, although it's not difficult. Just because it provides the methods doesn't mean you have to use them. That aside, CGI.pm can create any kind of HTML tag you want : if you use the OO interface, print $query->foo("hah!"); will output
<foo>hah!</foo>
To set attributes of such a tag, the first argument you give to the method or function must be a hash reference or anonymous hash that associates each attribute with its associated value. So, in this case,
print font( { color => "red" }, "This text is in red");
Will produce the following HTML :
<font color="red">This text is in red</font>
FWIW, though, being an up-to-date, let's-follow-w3c-recommendations kinda guy, I'd use
span({style=>"color:red"}, "This text is in red");
or style sheets to make text red.
Incidentally, your problem could be solved fairly simply: just embed the font tag in the text you're outputting, like so:
print p("I like <font color='red'>red</font> text"); # or print p("I like ", font({color=>"red"}, "red"), " text");
Or use here documents :
print <<END_OF_TEXT; <p>I like <font color="red">red</font> text.</p> END_OF_TEXT
Keep in mind that you *don't need* to use CGI.pm to generate all your HTML.
HTH.
perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'
|
|---|