Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Embeding Perl in HTML the PHP way

by aaron_baugher (Curate)
on Sep 11, 2012 at 22:33 UTC ( #993077=note: print w/replies, xml ) Need Help??

in reply to Embeding Perl in HTML the PHP way

Your example is how it's done in HTML::Mason, although the syntax would be slightly different. For one thing, you don't need the printf at all, since you're just printing a string. So you can do any of these:

<body> <% $some_string %> </body> <body> % print $some_string; </body> <body> <%perl> print $some_string; </%perl>

Like others here, I prefer frameworks these days. Mixing code with layout just doesn't scale well at all. Mason is better than PHP because it's Perl, but things still get ugly easily for some of the same reasons they do in PHP. Currently I'm using Dancer with Dancer::Template::Mason as my templating system, and liking that quite a bit. My templates are Mason, so they can use Perl code for things like loops, rather than requiring me to learn some new templating system's loop syntax. But since all my actual code that processes the data (Controller and Model, in MVC terms) is separate, the template files are still very clean.

Aaron B.
Available for small or large Perl jobs; see my home node.

Replies are listed 'Best First'.
Re^2: Embeding Perl in HTML the PHP way
by sundialsvc4 (Abbot) on Sep 12, 2012 at 00:14 UTC

    Yes, I think that everybody figured out pretty-quickly that the inline-code approach was an inferior approach ... particularly when I18N (internationalization) began to be a very big deal in this world-wide web of ours.   Really good templating systems, and then, really good web frameworks built on them, appeared in most language systems and all of them have matured along generally similar lines.   There is no reason to “go back,” and an abundance of reasons not to.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993077]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2017-12-16 02:48 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (447 votes). Check out past polls.