[dancer-users] Usage Of Plugins Out Of CPAN

Kadir Beyazlı kadirbeyazli at gmail.com
Mon May 25 21:53:44 BST 2015


Hi,

I understood how to use plugins which are already installed to CPAN.
I install it and use.
But how will I test my own plugins I wrote at local?

For example, I want to test following code taken from dancer manual
(https://metacpan.org/pod/Dancer2::Manual)

# Start of plugin
package Dancer2::Plugin::OnTuesday;
# ABSTRACT: Make sure a route only works on Tuesday
use Dancer2::Plugin;

register on_tuesday => sub {
    my ( $dsl, $route_sub, @args ) = plugin_args(@_);

    my $day = (localtime)[6];
    $day == 2 or return pass;

    return $route_sub->( $dsl, @args );
};

register_plugin;
# End of plugin

To be able to use above plugin at my local, I created .pm file at
following folder:

MyApp/lib/Dancer2/Plugin/OnTuesday.pm

I wrote following code at folder MyApp/test.pl

# Start of script
use Dancer2;
use lib "lib";

use Dancer2::Plugin::OnTuesday;

get '/' => on_tuesday => sub { return "tuesday" };

# every other day
get '/' => sub { return "other day" };

start;
# End of script

When I rub test.pl I got following error:

Can't locate Dancer2/Plugin/OnTuesday.pm in @INC


Kadir Beyazlı
Computer Engineer
GSM : +90 535 821 50 00


More information about the dancer-users mailing list