Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Can perl be injected on html pages?

by Nik
on Mar 30, 2009 at 10:57 UTC ( #754104=perlquestion: print w/ replies, xml ) Need Help??
Nik has asked for the wisdom of the Perl Monks concerning the following question:

Hello, is there a perl version that will allow pure perl code to be inserted into a pure html code/page acting like php works?

I am askign this for example because i would like to create nice html pages with use of expression web or dreamweaver and themn just inject perl code, for i.e. to create a counter, into the html page that those program created.

Comment on Can perl be injected on html pages?
Replies are listed 'Best First'.
Re: Can perl be injected on html pages?
by Corion (Pope) on Mar 30, 2009 at 10:59 UTC
      i saw a little about mod_perl but tis way more difficult in comparison with php. Is there a php type of approach with perl? (not that i like php better)
Re: Can perl be injected on html pages?
by dsheroh (Prior) on Mar 30, 2009 at 15:26 UTC
    Mason seems to be the most commonly-used "Perl embedded in HTML" option at the moment, although I seem to recall that you can do it with Template::Toolkit as well (even if the TT folks don't like to admit to it).

    But, as already mentioned, mixing logic with presentation like this is generally discouraged and is arguably the primary reason why PHP code has such a bad reputation as an unstructured mess. While it does work OK if you're just going to do something trivial like inserting a counter, it makes things much more difficult when you start trying to do anything more complex, so it's not a good habit to get into.

Re: Can perl be injected on html pages?
by jettero (Monsignor) on Mar 30, 2009 at 11:56 UTC

    I've used Embperl with success, but not since 2002.


Re: Can perl be injected on html pages?
by sundialsvc4 (Abbot) on Mar 30, 2009 at 12:42 UTC

    It is possible to accomplish this through regular-expressions ... searching for placeholders, extracting them, evaling the extracted text and substituting it back into the text. But as an architectural design I do not like this “commingling of concerns” and do not recommend it.

Re: Can perl be injected on html pages?
by chrisv (Initiate) on Mar 30, 2009 at 13:07 UTC


      pjf's jolly decent Mason presentation

      "Half of all adults in the United States say they have registered as an organ donor, although only some have purchased a motorcycle to show that they're really serious about it."
Re: Can perl be injected on html pages?
by Bloodnok (Vicar) on Mar 30, 2009 at 12:45 UTC
    Doesn't AS support something called perlscript ... or the like, for just such a purpose ?

    Admittedly tho', that does however pander to the M$ unique way of doing things...

    A user level that continues to overstate my experience :-))
      Perlscript, now there is something I haven't heard of in a long time!

      That was a browser plugin that let people execute Perl clientside. It required that people be using IE, and that they install the plugin, and then gave you nothing you couldn't get just as easily and far more portably with JavaScript.

      Unlike PHP and every Perl templating system that has been mentioned it did not have any access to anything on the server side.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://754104]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2016-05-28 15:04 GMT
Find Nodes?
    Voting Booth?