#!/usr/bin/perl use strict; use warnings; use diagnostics; use template; my $app = sub { my $html = get_html(); return [ 200, ['Content-Type' => 'text/html'], [$html], ]; }; sub get_html{ # open template file open(my $reader,'< :encoding(UTF-8)',"/library/webserver/documents/html.html"); my $input; do{$input .= $_} while(<$reader>); # Initialize HTML template my $template = Template->new(); my $vars = {greeting => 'Howdy, Cowboy!',debt => '$1.50',sender => 'John Wayne'}; my $html; $template->process(\$input,$vars,\$html) || die "Template process failed: ", $template->error(), "\n"; return $html; } #### Loan Shark

[% GET greeting %], It has come to our attention that your account is in arrears to the sum of [% GET debt %]. Please settle your account before the end of the year or you will face severe embarrassment. Yours truly, [% sender %]

##
## #!/usr/bin/perl use strict; use warnings; use diagnostics; use Plack::App::File; my $app = Plack::App::File->new(root => "/Library/Webserver/Documents")->to_app;