On Wed, May 27, 2009 at 4:21 AM, Raymond Wan <r....@aist.go.jp> wrote: > > Hi Joe, > > > jm wrote: >> >> then the <head> ... </head> code does not process correctly; it is >> ignored unless there is a 2nd pair of <head></head> tags in the print >> statement ("perl inline html") > > > In addition to Gunnar's questions, if you are still stuck, you need to also > clarify what "does not process correctly" mean. Obviously, you output to > some file -- do the "head" tags not show up? "Process" implies the step > after...whether or not your browser can view the page. That is somewhat > irrelevant. In the context of your code and your question, what matters is > what is in the file that is generated. > > If under both scenarios, the output file is identical (unlikely, given your > problem description), then the problem is related to the browser you are > using. > > Ray > >
a minor clarification: i'm not writing to a file, i'm creating several dynamically generated web pages. i'm trying to consolidate as many commonalities as possible for future maintenance. here's the bare bones version of the module: ########## package FF_Module; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(html_start); our $VERSION = 1.00; sub html_start { my %options = @_; # $options{title} = page title my $data = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\"> <head> <title>$options{title}</title> <link href=\"/css/style1.css\" rel=\"stylesheet\" type=\"text/css\" /> </head> "; return($data); } # end of sub html_start 1; ########## here's the minimal version of the program: ########## #!/usr/bin/perl use lib "/vservers/htdocs/modules"; use strict; use CGI qw(:all); use CGI::Carp qw(fatalsToBrowser); use FF_Module; my $page_start = &html_start(title => "Privacy Policy"); print " $page_start <head> </head> <body style=\"background-color: #330066;\"> <div style=\"background-color: #ffffff; width: 80%; text-align: center; margin-left: auto; margin-right: auto;\"> <p class=\"headings\" style=\"text-align: center;\">Privacy Policies</p> <p class=\"bodyText\">Student information is used only for enrollment and placement in classes and ensembles, and is not shared with any third parties whatsoever.</p> </div> </body> </html> "; ########## i have removed all elements not relevant to the problem at hand. the module sub has the required <head> ... </head> structure. note the 2nd pair of <head> tags in the program just below the $page_start variable (which also contains the <head> tags from the module sub). if i do not include the duplicate <head> tags in the print statement, the page is displayed as straight ascii text. as long as the duplicate tags are included the page displays properly. i can even comment them out and the page displays properly, but they have to physically exist a 2nd time. i have tried calling the sub with and without the leading ampersand, with no difference in results. I can insert the text from the module directly into the print statement (replacing the $options{title} with the desired text and removing the duplicate tags) and it works as expected. as per the rather cavalier suggestion to "ask w3c since it's not a perl problem", i have verified it against the w3c html validator page; it fails on the additional <head> and </head> tags and warns about a missing charset definition. since the duplicate tags w3c complains about come after the text from the module sub, w3c seems to find all that prior text acceptable and only the duplicate tags are a problem. this would imply that something in the way perl handles the module request/response regarding <head> tags (since they appear to have some type of special significance) or (far more likely) something in the way i'm handling the sub definition or call, though i can't discern anything i'm doing differently from what i've done successfully countless times before with other module subs joe -- since this is a gmail account, please verify the mailing list is included in the reply to addresses -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/