http://www.perlmonks.org?node_id=999960


in reply to PERL HTML HELP

Really this is less of a Perl question and more of an HTML question, but I'll bite.

My favorite way to render HTML pages is using HTML::Template which allows me to create a set of template files with "placeholders" that I use later to populate real data into the rendered page. I won't go into a whole tutorial on that here, but that's one thing to look at.

My second favorite is to use the CGI module. Example:

#!/usr/bin/perl -w use strict; use CGI qw/:all/; print start_html,p("Hello world"),end_html;
which produces:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body> <p>Hello world</p> </body> </html>
If your trying to output to a file instead of STDOUT you'd do something like this:
#!/usr/bin/perl -w use strict; use CGI qw/:all/; open FOUT,"> my_html_page.html" or die $!; print FOUT start_html,p("Hello world"),end_html;

As far as each letter having a different color goes I'm not sure what you are after but if I want to change the color of some text it's going to look something like:

#!/usr/bin/perl -w use strict; use CGI qw/:all/; print start_html,p({ style => "color: red;"},"Hello world"),end_html;
and if you're using a CSS sheet and have a class or id set up for what you want you can invoke it with {id => "foo"} just as I did with the style invocation above.

As far as keeping your columns even and forcing a wraparound within a cell goes, that is strictly and HTML issue. Here (from a Perl perspective) what that looks like:

print table({width=>'80%',tr(td({width=>'30%',"thing1"), td({width=>'60%',"thing2"), td({width=>'10%',"a really long thing") ));
The very right most column being the smallest and depending on the screen size should wrap nicely.

There are other subtleties to explore in a combination of Perl-fu and HTML-fu and are beyond the scope of this thread.


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg