index.pl (Plain text version)

#!/usr/bin/perl
use PerlHP;

<%
	use strict;

	my $tagline=random_line("taglines.txt")
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>PerlHP - <% print $tagline %></title>

<style type="text/css">
body { padding: 0em 1em; }
h1 { background:#eef; font-family: sans-serif; font-size: 1.5em; font-weight: bold; border-bottom:2px solid #ccf }
h2 { color: #336; font-family: sans-serif; font-size: 1.2em; font-weight: bold; border-bottom:1px solid #ddf }
h3 { font-size: 1em; font-weight: bold; }
a { color: #f83; font-family: sans-serif; }
a:visited { color: #d72; }
a:hover { color: #fff; background: #f83; text-decoration: none; }
#footer { font-size: 0.7em; margin-top: 2em; text-align: center; }
#comments { border-top: 1px dashed #ddf; margin-top: 1em }

blockquote { margin-left: 0em; }
blockquote blockquote { font-style: italic; margin-left: 0em; color: #7f7f7f; }
blockquote blockquote em { font-style: normal }
p.signature { border-bottom: 1px dashed #ddf; padding: 0em 0em 0.5em 4em }
p.signature:before { content: "- " }
input, textarea { border: 1px solid #448 ; background: #fff }
input[type=submit] { color: #448; }
input:hover[type=submit] { background: #ccf }
label { font-family: sans-serif; color: #448; }

.fuckoffspammers { display: none; }

</style>

<body>

<h1>PerlHP - <% print $tagline %></h1>

<h2>Introduction</h2>

<p><abbr title="Perl HomePage tools">PerlHP</abbr> is an attempt to give Perl the same
simplicity and hackiness that PHP has spent years trying to forget. It lets you
put together simple dynamic web pages more quickly than writing them in plain Perl, and
with less mental anguish than writing them in PHP. It is also cheerfully obfuscated,
but luckily you don't need to actually look at it to use it.</p>

<p><abbr title="Perl Hypertext Processor">PerlHP</abbr> started out as a <a href="http://4-ch.net/code/kareha.pl/1105183272/">joke</a>,
but it did turn out to be useful - for instance, I wrote this page using it. It can
reduce both PHP and Perl programmers to incoherent rambling, which I also view as a
success.</p>

<p><abbr title="Perl HP sauce">PerlHP</abbr> works best on a web server with Perl 5.8.0 or
newer, but will also run on Perl 5.6.0 with some tweaking. The current version of PerlHP
is <strong>SE v9.0</strong>.</p>


<h2>Getting it</h2>

<p>There is no automatic installer for PerlHP yet. It is just a single <code>.pm</code> file,
and can either be copied into the Perl <code>lib/</code> directory, or kept in the same
directory as your pages.</p>

<ul>
<li><a href="PerlHP.pm">The main PerlHP file</a></li>
<li><a href="PerlHP.html">The PerlHP documentation</a></li>
<li><a href="viewsource.pl/PerlHP.pm">Look at the source</a></li>
</ul>

<h2>Example code</h2>

<ul>
<li><a href="test.pl">A simple test page</a> (<a href="viewsource.pl/test.pl">source</a>)</li>
<li><a href="manfire/manfire.cgi">An image browser</a> (<a href="viewsource.pl/manfire/manfire.cgi">source</a>)</li>
<li><a href="viewsource.pl/index.pl">The source for this page</a></li>
<li><a href="viewsource.pl/viewsource.pl">The source code viewer</a></li>
</ul>

<h2>Alternatives</h2>

<p><a href="http://onperl.org/">Michael J. Matthews</a> has converted PerlHP into
a slightly more sane templating engine, and created a CPAN module for it, named
<a href="http://search.cpan.org/~mmathews/Markup-Perl/lib/Markup/Perl.pm">Markup::Perl</a>.
This is a good option for people who are not crazy, or just prefer to use code off
CPAN. It has most of the same benefits as PerlHP.</p>


<h2>Release notes</h2>

<h3>SE v9.0:</h3>
<ul>
<li><code>use strict;</code> now fully supported. It is recommended that you use
this - see the documentation for
<a href="http://wakaba.c3.cx/perlhp/PerlHP.html#use_strict_">details</a>.</li>
<li>Re-written parser to properly support including external files with
<code>do</code> and <code>require</code>.
<li>PHP-style short tags (<code>&lt;%= expression %&gt;</code>) are now supported,
and code sections are now implicitly closed at EOF.</li>
<li>No longer uses a temporary file for output, which gives a slight speedup.</li>
<li>Added a PHP-stlye <code>echo()</code> function and <code>%_REQUEST</code>
hash.</li>
<li><code>readfile()</code> function added to quickly read external files.</li>
<li>Under Perl 5.6.*, the <code>use PerlHP;</code> statement is now required.</li>
<li><code>perlhp()</code> function for parsing PerlHP code to Perl code added,
to be used for silly hacks.</li>
<li>Some error reporting bugs fixed.</li>
</ul>

<h3>v5.0.1</h3>

<ul>
<li>Security fix!</li>
</ul>

<h3>v5.0</h3>

<ul>
<li><a href="http://wakaba.c3.cx/perlhp/PerlHP.html#perl_5_6__">Perl 5.6.* support</a></li>
</ul>

<h3>v3.01 Gold</h3>

<ul>
<li>Beautiful error handling</li>
<li>Bugfixes</li>
</ul>


<h2>Links</h2>

<ul>
<li>PerlHP discussion and support requests are welcome in the 
<a href="http://wakaba.c3.cx/sup/kareha.pl/1106443916">PerlHP thread</a>
at the <a href="/sup/">Wakaba and Kareha support board</a>.</li>
<li>The <a href="http://www.4-ch.net/code/">4-ch Programming Board</a> is also a good place
to discuss PerlHP and other programming matters.</li>
<li>I've also written several <a href="/">message board scripts</a>, which are used in
such places as <a href="http://www.wakachan.net/">WAKAchan</a> and
<a href="http://www.4-ch.net/">4-ch</a>.</li>
</ul>

</div>

<p id="footer">- Powered by PerlHP -</p>

</body>

<%
sub random_line($)
{
	my ($file)=@_;
	my @lines=read_array($file);
	return $lines[rand @lines];
}

sub read_array($)
{
	my ($file)=@_;

	open FILE,$file or return ();
	my @array=map { s/\r?\n?$//; $_ } <FILE>;
	close FILE;
	return @array;
}

%>