Introduction to Perl dancer framework

In this tutorial, we are going to learn about the introduction to Perl dancer framework.
Submitted by Godwill Tetah, on December 03, 2020

In this tutorial, we will get started with Perl Dancer. Perl Dancer is a web framework written in Perl used to build websites or web applications. Dancer is just one of the awesome frameworks written in Perl used to build web applications. There are other Perl frameworks used too.

Dancer is quite simple to understand for anyone who has done web development before. More about Dancer or more Perl modules can be found on Just open the website and search for any module you wish to know more about by typing it in the search box.

I want you to understand that there are several ways to do that same thing in computer science, but we will simplify it for better comprehension.


Remember Dancer is a framework that doesn't come in-built with Perl, so it must be installed as a Perl module before usage.

In this tutorial, we will install Dancer through "cpanminus".

Cpanminus enables Perl developers to install Perl modules from their command line.

To install cpanminus, run the command below on your command line and wait till it displays successful installation. Internet connection is required when installing any module from Perl's ecosystem of modules.

Perl dancer framework (1)

Now that we are done installing cpanminus, we will move on to installing Dancer using cpanminus. To achieve this, run the command;

Perl dancer framework (2)

Wait until it displays a message showing that installation complete.

Now let's see if it was finally installed by running a short code. After installation, coding and development can now be done offline. We're just on development mode!

use Dancer;
get '/' => sub {
    return "hello world!, i can now use Perl for web dev";

Above is a simple code in the file Start the web page by simply running the command below; perl where is the file name.

Perl dancer framework (3)

The output on the console means everything is successful and can be opened in localhost:3000 in a browser.


Perl dancer framework (4)

And finally, that's the expected output.

Comments and Discussions!

Load comments ↻

Copyright © 2024 All rights reserved.