Skip to content

Instantly share code, notes, and snippets.

use Dancer;
use MyTop::MyMiddle::MeetingAlerts;
use Plack::Builder;
my $app = sub {
my $env = shift;
my $request = Dancer::Request->new(env=>$env);
Dancer->dance($request);
};
@msouth
msouth / gist:5029672
Created February 25, 2013 13:00
Lines in Dancer cookbook that look unnecessary to me
# bin/script2.pl
#unnecessary use FindBin;
#unnecessary use Cwd qw/realpath/;
use Dancer ':script';
=pod
Dancer already knows this
#tell the Dancer where the app lives
use strict;
use warnings;
while (<DATA>) {
s/[<>]//g;
s{\[((/)?(b|i|s))\]}{<$1>}g;
print;
}
__DATA__
use strict;
#########################################
############# would be in Animal.pm normally
#########################################
package Animal;
sub new {
my $package = shift;
# this 'bless' call tells that anonymous hash "if someone calls ->foo on you, look in $package for a sub named 'foo',
use DBI;
use strict;
use warnings;
my $db_name = shift or die "call as $0 [database_name] [mysql user] [mysql password]";
my $mysql_user = shift || 'root';
my $mysql_password = shift || '';
my $dbh = DBI->connect("dbi:mysql:database=$db_name", $mysql_user, $mysql_password) || die DBI->errstr;