FAQ

#!/usr/bin/perl use strict; use CGI; use CGI::Session; use CGI::Carp qw/ fatalsToBrowser /; use XML::Simple; my $cgi = new CGI; print $cgi->header(); my $xs = new XML::Simple; my $xml = $xs->XMLin("dat.xml"); if (my $article = $cgi->param('page')) { my $item = load_item($xml, $article); print $item->{content}; } sub menu { my $xml = shift; my @r; for (sort {$a->{order} <=> $b->{order} } @{$xml->{article}}) { push @r, { title => "edit $_->{title} page »", link => "?action=edit&page=$_->{title}" }; } push @r, { title => 'Logout »', link => '?action=logout' }; return @r; } sub load_item { my $xml = shift; my $target = shift || return; for (@{$xml->{article}}) { return $_ if $_->{title} eq $target; } }