Fork me on GitHub

A next generation web framework for the Perl programming language.

Back in the early days of the web, many people learned Perl because of a wonderful Perl library called CGI. It was simple enough to get started without knowing much about the language and powerful enough to keep you going, learning by doing was much fun. While most of the techniques used are outdated now, the idea behind it is not. Mojolicious is a new attempt at implementing this idea using state of the art technology.

Features

Installation

All you need is a one-liner, it takes less than a minute.

$ curl get.mojolicio.us | sh

We recommend the use of a Perlbrew environment.

Getting Started

These three lines are a whole web application.

use Mojolicious::Lite;

get '/' => {text => 'I ♥ Mojolicious!'};

app->start;

To run this example with the built-in development web server just put the code into a file and start it with morbo.

$ morbo hello.pl
Server available at http://127.0.0.1:3000.

$ curl http://127.0.0.1:3000/
I ♥ Mojolicious!

Duct tape for the HTML5 web

Use all the latest Perl and HTML features in single file prototypes like this one and grow them easily into well-structured applications.

use Mojolicious::Lite;
use 5.20.0;
use experimental 'signatures';

# Render template "index.html.ep" from the DATA section
get '/' => {template => 'index'};

# WebSocket service used by the template to extract the title from a web site
websocket '/title' => sub ($c) {
  $c->on(message => sub ($c, $msg) {
    my $title = $c->ua->get($msg)->res->dom->at('title')->text;
    $c->send($title);
  });
};

app->start;
__DATA__

@@ index.html.ep
% my $url = url_for 'title';
<script>
  var ws = new WebSocket('<%= $url->to_abs %>');
  ws.onmessage = function (event) { document.body.innerHTML += event.data };
  ws.onopen    = function (event) { ws.send('http://mojolicio.us') };
</script>

Perl might be over 25 years old, but it is still an evolving language with a yearly release cycle. We strongly recommend that you update regularly. Subroutine signatures is just one of many new features.

Want to know more?

Take a look at our excellent documentation!