Quick question, instead of doing a while(<HTML>){$template .= $_;}
couldn't you just localize $/ and then slurp the file into $template?
In other words, do this:
sub getTemplate {
my ($t,$template);
return undef unless $t = $_[0];
local $/ = undef;
open(HTML, $_[0]) || print "Could not open $t: $!";
$template = <HTML>;
close(HTML);
return $template;
}
To the Gurus: Would this be faster or the same as doing it with the
while?
#!/usr/bin/Brian Johnson
$job = "Laziness";
$pay = 0;
$motivation = "None";
$business = "Source1Results.com, LLC";
$website = "www.source1results.com";
if($contact_brian) {
$sendmail = "brianj\@source1results.com";
}
>
> My solution is a little more general. I wrote this so my CGI
> could fit into
> HTML created using Dreamweaver templates. In the Dreamweaver template
> wherever I want my perl to write, I put a unique string, like
> "perlinsert".
> Then I call a subroutine to put the html into an array, and
> print it as
> needed.
>
> my @html = split(/"perlinsert"/, getTemplate("template.htm"));
>
> print $cgi->header, $html[0];
> #perl code to print into section 1
> print $html[1];
> #perl code to print to next section...
>
> #---------------Get the HTML template from an .htm
> file-----------------
> sub getTemplate(){
> my $t = @_[0];
> my $template = "";
> open(HTML, $t) || print "The file you are accessing cannot
> be opened";
> while(<HTML>){$template .= $_;}
> close(HTML);
> return $template;
> }
>
> Then when I update the Dreamweaver template, the CGI's all
> get the updates
> as well.
>
>
>
> ----- Original Message -----
> From: Vinicius Jose Latorre <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Friday, August 03, 2001 7:35 AM
> Subject: Re: cgi and html
>
>
> >
> > --- "Curtis Poe" <[EMAIL PROTECTED]> wrote:
> >
> > > --- "Boex,Matthew W." <[EMAIL PROTECTED]> wrote:
> > > >
> > > > i need to incorporate a good deal of html into my cgi
> scripts. what
> are my
> > > > options other than Html::Mason. i know that will do
> the job but just
> want
> > > > to compare against any other solutions out there....
> > > >
> > > > matt
> > >
> > > Two options come to mind offhand.
> > >
> > > We use Template Toolkit where I work
> (http://www.template-toolkit.org/).
> There's a bit of a
> > >
> learning curve but it's incredibly powerful and fast. Also, it's not
> limited to HTML. You can
> > > use it with business documents, XML, whatever you want to
> template.
> > >
> > > HTML::Template is a nice, lightweight option that's
> ridiculously easy to
> use. I wrote up a quick
> > > start guide for it
> (http://www.perlmonks.org/index.pl?node_id=> 46976)
> which also
> explains *why* one
> > > would want to use templates.
> > >
> >
> > CGI::Application is also another good package and it uses
> HTML::Template
> > (http://www.perl.com/pub/a/2001/06/05/cgi.html).
> >
> >
> > Vinicius
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]