##
$_ = qq|
1
d4 f5 2 Nc3 d5 3 Bg5 c6 4 e4 fxe4 5 f3 exf3 6 Nxf3 Bg4 7 h3 Bxf3 8
Qxf3 Nf6 9 Bd3 Nbd7 10 0-0-0 Qc7 11 Rhe1 0-0-0 12 Bf4 Qb6 13
Re6 g6 14 Nb5 Ne8 15 Be2 a6 16 Qa3 g5 17 Na7+!! Qxa7 18 Rxc6+! bxc\
6 19 Bxa6+ Qb7 20 Qa5
|;
s{\b(\d+)\b}{\1.}g;
print;
##
##
use strict;
use CGI;
use Template;
$|++;
# Dispatch table is a hash where
# every value is a sub-reference
# When the user doesn't provide
# a run-mode, then list() is
# triggered (default case, see
# the last line
my %dispatch_table = (
list => \&list,
item => \&item,
fetch_image => \&fetch_image,
'' => \&list,
);
my $query = new CGI;
print $query->header;
print $query->start_html(
-title => 'A small example...'
);
# Now we read the param mode from
# the query. The string is used to
# fetch the hash table. We got a
# reference to a function, so we
# can call it...
my $mode = $query->param('mode');
&{ $dispatch_table{$mode}};
print $query->end_html;
sub list
{
print "List mode
\n";
my $action = $query->param('action');
# What we can do with $action?
# Another dispatch table here is not
# possible (one can't define procedures
# local to other procedures, like in
# Pascal). Another possibility is to
# define other procedures "at the same
# level" of list(), item() and so on...
# but it isn't elegant and easily maintanable.
# So we could use different
# packages for different "top level run-modes".
# Or, simply, we can cope with $action
# here, with a if-elsif-else construct.
}
sub item
{
print "Item mode
\n";
}
sub fetch_image
{
print "Fetch_image mode
\n";
}
##
##
# Modified by larsen - Nov 17 2001
[%
use Everything::Experience;
return unless $NODE->{imgsrc};
my $SETTING = getNode('home node image cheaters','setting');
my $CHEATERS = getVars $SETTING;
return unless isGod($NODE) or
getLevel($NODE) >= 5 or
$CHEATERS->{$NODE->{title}} or
$CHEATERS->{$NODE->{node_id}};
return qq(
);
%]
[%
use Everything::Experience;
if ($NODE->{imgsrc} and getLevel($NODE)<5 and !isGod($NODE))
return linkNodeTitle("I want my picture back|*");
return "";
%]
User since:
[{parsetime:createtime}]
Last here:
[{parsetime:lasttime}]
([{timesince:$NODE->{lasttime}}])
Experience:
[% $NODE->{experience} || "none yet" %]
Level:
[%
use Everything::Experience;
my $lvl = getLevel($NODE);
my $LT = getVars(getNode('level titles', 'setting'));
my %is_inquisitor = ();
# larsen - Nov 17 2001
# Maybe an hash here is overkill.
# Since there are only two Inquisitors,
# a simple OR clause could be fine.
foreach( qw|larsen OeufMayo| ) $is_inquisitor{ $_ }++;
my $leveltitle;
if ($is_inquisitor{ $NODE->{title} }) {
$leveltitle = 'Inquisitor';
} else {
$leveltitle=$LT->{$lvl};
}
return $leveltitle . " ($lvl)";
%]
Writeups:
[%
my $count = htmlcode('displaySingleVar', 'numwriteups');
$count ||= 0;
my $title = $NODE->{title};
$title =~ s/ /\+/g;
"$count";
%]
Location:
[{displaySingleVar:location}]
User's localtime:
[%
my $USERVARS = getVars($NODE);
htmlcode('userlocaltime', $USERVARS->{timezone});
%]
User's scratchpad:
[%
# crazyinsomniac Sat Nov 3 00:39:08 2001 GMT
my $USERVARS = getVars($NODE);
if($$USERVARS{scratchpublic})
{
return qq( this pad be public, scratch it);
}
else {
return "not public";
}
%]
[%
use Everything::Experience;
my $str;
$str .= htmlcode('parselinks', 'doctext,override');
$str =~ s///igs
unless(getLevel($NODE)>=5 or isGod($NODE));
$str =~ s/