Hi,

I'm trying to concatenate some strings and a CGI variable together so I can create the template name to be used in my program. Below is what I have, but I get the error message,

"HTML::Template->new() : Cannot open included file $rpt_tmpl : file not found. at HTML/Template.pm line 1580".

Am I using HTML::Template incorrectly? If I hard-code what I want (cnc1_rpt1_summary.tmpl), it works beautimously and my $rpt_id value is "1".

Thanks for any help you can provide!

#!/usr/local/bin/perl5_8 use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); #remove for PRD use HTML::Template; use DBI; use My::pswd; my $CGI = CGI->new; $|=1; print "content-type: text/html\n\n"; my $err; my $server = $My::pswd::server; my $userid = $My::pswd::userid; my $passwd = $My::pswd::passwd; my $rpt_id = $CGI->param('rpt_id'); my $proj_id = $CGI->param('proj_id'); my $rpt_asofdt = $CGI->param('rpt_asofdt'); my $rpt_tmpl = "cnc1_rpt" . "$rpt_id" . "_summary.tmpl"; my $template = HTML::Template->new( filename => '$rpt_tmpl', associate => $CGI, ); #.... and then a bunch of other stuff (fetch data, #fetch futzed (for now) params to pass to template .... print $template->output(); #temp: just to show my variable values; remove for PRD print "my rpt_id is: $rpt_id<br>"; print "my proj_id is: $proj_id<br>"; print "my rpt_asofdt is: $rpt_asofdt<br>"; print "Good-bye Cruel World.\n";

Lori


In reply to HTML::Template, CGI - concatenating strings & variables by Lori713

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.