For developers. Examples.

We'll make a static page "hello world" at

To do this, lets create a file


in modules folder and fill it the following:



use strict;
    '/hello' => sub {
        return "hello, world!";


Lets make a dynamic page "hello WHATEVER" at

To do this, edit the file



use strict;
    '/hello/(\w+)' => sub {
        return "hello, $1!";


Now you can put any one word in the URL instead of WHATEVER word.


Creating of dynamic page, that shows the weather forecast for London city

To do this, we kindly use the RSS from site. Please, create file


in modules folder and write:


use strict;
use XML::RSS::Parser::Lite;
use LWP::Simple;
    '/weather' => sub {
# Taking the rss feed and parsing it
        my $xml = get( "" );
        my $rp = new XML::RSS::Parser::Lite;
# Template Toolkit loads weather.tpl template with parameters:  rp_count - the number of sections in the rss,
# rp - function with input data: section number, name of the section, output data is contents of the section
process( 'weather.tpl', {
rp=>sub{ my $it = $rp->get($_[0]); $it->get($_[1]); }
}, };


Please, create file


in templates directory with following:


<h1>Weather in London</h1>
[% WHILE rp_count>0 %]
    [% rp_count = rp_count - 1 %]
    <b>[% rp(rp_count,'title') %]</b><br />
    [% rp(rp_count,'description') %]<br />
    <hr />
[% END %]


Now the weather in London is displayed at

Finally, you can change the script and template to show the weather forecast in any city, you can cache information until the end of the day, and you can make multilingual weather page. Description for developers in preparation.


back to page about the system