I know of no simpler solution than what is provided by a Mojolicious::Lite framework (see the Mojolicious website).

#!/usr/bin/env perl use Mojolicious::Lite; get '/index' => sub { my $self = shift; $self->render('index', some_string => "Hello world!!!" ); }; app->start; __DATA__ @@ index.html.ep <!DOCTYPE html> <html> <head> <title>Hello world</title> </head> <body> <%= $some_string %> </body> </html>

Let's say you call that "myapp.pl". Run it like this: ./myapp.pl daemon. Point your browser to http://localhost:3000/index.html.

Deployment options are covered here: Mojolicious::Guides::Cookbook#DEPLOYMENT.

This is a minimal example. In a real app you would want to reduce the redundancy somewhat between templates by using layouts. And you would define more routes, of course. ...and probably set index up as a default fallback route. For example:

get '/goodbye' => sub { $_[0]->render( 'goodbye', some_string => "Goodbye world!" ); }; get '/*fallback' => { fallback => 'index' } => sub { $_[0]->render( 'index', some_string => "Hello world!\n" ); }; __DATA__ @@ index.html.ep ........ @@ goodbye.html.ep ...........

The fallback is defined as your last route so that it doesn't try to take over unless no other routes matched. Also you would probably eventually inflate the app so that the templates can each live in their own files. Any pages that are truly static content will reside in public/.


Dave


In reply to Re: Embeding Perl in HTML the PHP way by davido
in thread Embeding Perl in HTML the PHP way by heatblazer

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.