|
|
Subject:
PERL command to print HTML file
Category: Computers > Algorithms Asked by: cluelessone-ga List Price: $5.00 |
Posted:
17 May 2006 06:56 PDT
Expires: 16 Jun 2006 06:56 PDT Question ID: 729718 |
I need a PERL command that will "print" the contents of an HTML file. I want to create some complicated HTML, save it in a file, and then have my PERL script show that to the user. Including the HTML in the PERL script makes it difficult to update, easier to do it in an external file. |
|
Subject:
Re: PERL command to print HTML file
Answered By: palitoy-ga on 17 May 2006 07:12 PDT Rated: |
Hello cluelessone-ga, Thank-you for your question. The easiest way to do this is to collect all the information you have output into the HTML file and print it on the screen. This can be done using this small snippet. If you have any questions or require any further assistance please do not hesitate to ask for clarification. # read the html file into an array open (TXTFILE, "/path/to/file.html"); @lines = <TXTFILE>; close(TXTFILE); # place the contents of the @lines array into a variable $all_lines = join("",@lines); # replace the < character with its HTML equivalent < # this enables the code to be viewable $all_lines =~ s/</\</g; print $all_lines; |
cluelessone-ga rated this answer: |
|
Subject:
Re: PERL command to print HTML file
From: frankcorrao-ga on 17 May 2006 09:13 PDT |
it sounds to me like what you really need here is a templating system. The standard way to do this is with the HTML::Template package: http://sam.tregar.com/html_template.html If you are unfamilair with what i mean by "html templating", basically you save an html file that has special tags which let you inline variables and loops etc from perl. Then in your perl script, you set the variables etc. Like magic, everything is replaced in the html file with the values of the variables from your perl script. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |