janharders

msg:4283293 | 8:52 pm on Mar 17, 2011 (gmt 0) |
Yes, but not with your standard apache environment. You could use something like the Mason suite of modules that's allow you to go with <ul> % while (my ($key,$value) = each(%ENV)) { <li> <b><% $key %></b>: <% $value %> </li> % } </ul> or Dear <% $name %>: We will come to your house at <% $address %> in the fair city of <% $city %> to deliver your $<% $amount %> dollar prize!
The answer is <% ($y+8) % 2 %>.
You are <% $age < 18 ? 'not' : '' %> permitted to enter this site. and more. Is that what you need?
|
jalarie

msg:4283301 | 9:19 pm on Mar 17, 2011 (gmt 0) |
I don't see anything in your code that tells the server to use the Mason suite. How is that done?
|
phranque

msg:4283336 | 10:13 pm on Mar 17, 2011 (gmt 0) |
Mason - search.cpan.org: http://search.cpan.org/~jswartz/Mason/lib/Mason.pm [search.cpan.org]
|
jalarie

msg:4283364 | 11:06 pm on Mar 17, 2011 (gmt 0) |
As far as I can see, Mason is used to generate the web page from within a Perl program. I know how to do that. I want to use Perl statements from within an existing web page. I saw instructions on how to do it; tried it; got it to work; and then, rather stupidly, deleted the working page and the link to the internet location where I found the instructions.
|
phranque

msg:4283402 | 12:51 am on Mar 18, 2011 (gmt 0) |
| within an existing web page |
| are you looking for a server side method to process embedded perl or a client/user agent-type solution?
|
jalarie

msg:4283418 | 1:20 am on Mar 18, 2011 (gmt 0) |
I wish to do it server-side so that it works for everyone.
|
phranque

msg:4283527 | 7:40 am on Mar 18, 2011 (gmt 0) |
Mason is perl code embedded in <%perl> tags within a (x)html document. Mason uses a handler to serve the html with embedded perl document, similar to the mechanism used to serve cgi scripts. if Mason isn't suitable to your requirements or doesn't match your style you might try HTML::Embperl: http://search.cpan.org/~grichter/HTML-Embperl/Embperl.pod [search.cpan.org]
|
jalarie

msg:4283700 | 3:09 pm on Mar 18, 2011 (gmt 0) |
According to the documentation, Mason has to be installed on the server, and I don't have access to do that. Embperl is a Perl program which processes an input file to produce HTML output. I'd really like to do this totally within HTML without installing anything on the server. I had it working but deleted it. Nuts!
|
rocknbil

msg:4283745 | 4:38 pm on Mar 18, 2011 (gmt 0) |
There are two ways off the top of my head that will work for this, but it's not actually embedding perl "in the page." The first and most obvious: - make sure you can set .html extensions to be parsed by server side includes, OR change your html extensions to .shtml so they will be parsed by server side includes. - Wherever you'd include "perl output," do this. <!--#include virtual="/path/to/yourscript.pl" --> or (some servers won't let you exec) <!--#exec cmd="perl /path/to/yourscript.pl"--> or <!--#exec cgi="/path/to/yourscript.pl" --> and you can even pass parameters; yourscript.pl would accept parameters via @ARGS <!--#include virtual="/path/to/yourscript.pl blah=1 bleah=2" --> or query string . . . <!--#include virtual="/path/to/yourscript.pl?blah=1&bleah=2" --> The advantage of the second is if you have a script that will be included OR called from the web it will work in either case without modification. The second and probably more manageable method, though it would take a bit more programming, is to use the actual HTML files as "templates" and use "markers" where you would expect perl output. Looks like Mason is doing something "like" this, another is Template::Toolkit (which may already be installed in your environment.) The advantage of this method is you don't need multiple requests for various scripts; you call a single script and it parses out the page as a template, replacing the markers with your data.
|
|