Hi Monks,

I've got 10-20 text files that I want to include in one HTML file so a user would see one big scrollable set of data in the browser(and be able to use the browser search feature). As far as I can tell there isn't an HTML method/tag to include external text files like this. I was thinking about using Perl to directly manipulate the HTML file but that will be messy and error prone because not only would I need to append the text files in to one big HTML file but might have to remove sections as well. The text files are generated by another process and there's no guarantee of the file being present, the size, or content being predictable.

I've looked at HTML::Pager and HTML::Template and have been trying to get the latter working without success to open a filehandle and then display the contents. I'll be using CGI too because I want to get user input.

Am I even close or is there a better way to do this?

#template2.pl c:\perl\bin\perl.exe use warnings; use strict; use CGI; use HTML::Template; my $template = HTML::Template->new(filename => 'c:\inetpub\wwwroot\cgi +-bin\template2.tmpl'); open(FH, 'c:\temp\output.txt') || die("Can't open output.txt: $!"); my $ioref = \*FH; $template->param(FILE => "$ioref"); $template->param(PATH => 'yellow brick road'); print "Content-Type: text/html\n\n", $template->output
#template2.tmpl <html> <head><title>Test Template</title> <body> Contents of file are <TMPL_VAR NAME=FILE> <p> Path is set to <TMPL_VAR NAME=PATH> </body> </html>
This doesn't work, and instead prints
Contents of file are GLOB(0x152ab4c) Path is set to yellow brick road
Thank-you for your time.

In reply to HTML::Template and filehandle ? by gctaylor1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.