I m new to Perl programming. How can I use it instead of PHP? In Xampp or PHP we have "htdocs" to store our .php files but how could I save my .pl file?
当我试图通过当地东道方开一个插座时,整个档案可以下载,而与我们在打开一个.php时不同的是,已经执行《php》法典。
I m new to Perl programming. How can I use it instead of PHP? In Xampp or PHP we have "htdocs" to store our .php files but how could I save my .pl file?
当我试图通过当地东道方开一个插座时,整个档案可以下载,而与我们在打开一个.php时不同的是,已经执行《php》法典。
The simplest option is to configure your web server to support CGI and then write your Perl to follow the CGI protocol (the CGI module is helpful for this). You can configure servers to execute any file with a .pl extension if you wish.
Slightly more complicated, but more flexible, is PSGI/Plack. This is a set of middleware that you can hook up to a web server in a variety of ways (e.g. FastCGI or mod_perl) for better performance. This also gives some nice debugging options. There is an advent calendar style guide that you might find useful.
XoR已经提到过,但我要重申:Mojolicious! 它有一个排气发动机,使你能够使用超文本的六氯代醇编码,但你可以在申请中做大部分重提。 工作还包括(每台)网络服务器(一台用于测试,一台用于生产),其使用比阿帕奇要容易得多。
Easy to install: just install Mojolicious
using cpan
(or other).
撰写基本文字:(一) 简便的世界:
#!/usr/bin/env perl
use strict;
use warnings;
use Mojolicious::Lite;
get /(:name) => {name => World } => sub {
my $self = shift;
$self->render( index );
};
app->start;
__DATA__
@@ index.html.ep
<!DOCTYPE html><html>
<head>
<title> Hello <%= $name %> </title>
</head>
<body>
Hello <%= $name %>
</body>
</html>
操作:morbo myapp.pl
从宽处理的方法来看,它像你的网络服务器一样,是适当配置的;它应当解释档案,而不是将其归档。
奇怪的是,如果你知道PHP,那么你为什么会用Perl来网吧? 我认为我读过一条,而后又说,在显示网页时,PHP比Perl更快。
见。
If you want to start with Perl5 web development it is usefull to start with CGI, but that is not necesity.
There is CGI module. You could look at how HTTP works and how Apache or whatever server you use calls your CGI program. Good start is using this script:
#!/usr/bin/env perl
use strict;
use warnings;
print "Content-type: text/html
";
print "<html>";
print "<body>";
print "<table>";
for my $var_name (keys %ENV) {
print "<tr>";
print "<td>$var_name</td>";
print "<td>$ENV{$var_name}</td>", "
";
print "</tr>"
}
print "</table>";
print "</body>";
print "</html>";
Then looking at variables like "REQUEST_URI", "REQUEST_METHOD" and "QUERY_STRING", you can get idea what CGI module is doing in background.
It s important to know that your script must be at directory that is set up to run cgi scripts, like:
ScriptAlias /cgi_bin/ /var/cgi_bin/
<Directory /var/cgi_bin/>
Options +ExecCGI
AddHandler cgi-script .cgi .pl
</Directory>
操作服务器的任何用户(例如阿帕奇2)都必须对文档进行迫害,并且可以读。
Also after this you can look at modern toolkits like Catalyst & Mojolicious. I recomend you mojolicious. Also there is web framework called Dancer.
About frameworks, Catalyst is long time here and it works, but it kind of took some kraft with it. This is tried to be fixed with new frameworks like mojolicious. Mojolicious don t have almost no external CPAN dependencies.
I am building a Web interface to monitor an embedded system. I have built a Perl script which runs remote commands and gathers output from that system. Now what I need is a Web interface which makes ...
How do I tell what type of value is in a Perl variable? $x might be a scalar, a ref to an array or a ref to a hash (or maybe other things).
When I try a "chdir" with a filehandle as argument, "chdir" returns 0 and a pwd returns still the same directory. Should that be so? I tried this, because in the documentation to chdir I found: "...
I ve read the doc for GetOptions but I can t seem to find what I need... (maybe I am blind) What I want to do is to parse command line like this myperlscript.pl -mode [sth] [inputfile] I can use ...
I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...
I would like to submit a form to a CGI script localy (w3c-markup-validator), but it is too slow using curl and apache, I want to use this CGI script more than 5,000 times in an another script. and ...
So I m running perl 5.10 on a core 2 duo macbook pro compiled with threading support: usethreads=define, useithreads=define. I ve got a simple script to read 4 gzipped files containing aroud 750000 ...
A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...