Odd number of elements in anonymous hash at /usr/local/share/perl5/Plack/Middleware.pm line 14 #864

Closed
gecon opened this Issue Nov 21, 2012 · 3 comments

3 participants

@gecon

Always getting message:
Odd number of elements in anonymous hash at /usr/local/share/perl5/Plack/Middleware.pm line 14

when starting a simple test app through Plack (starman).

More info:

#  starman -E development --workers=1 -p 8082 app1.pl
2012/11/22-00:12:49 Starman::Server (type Net::Server::PreFork) starting! pid(25946)
Resolved [*]:8082 to [0.0.0.0]:8082, IPv4
Binding to TCP port 8082 on host 0.0.0.0 with IPv4
Setting gid to "0 0 0 1 2 3 4 6 10"
Starman: Accepting connections at http://*:8082/
[25947]  core @0.000010> PLACK_ENV is set (development) forcing PSGI handler in /usr/local/share/perl5/Dancer/Handler.pm l. 31
[25947]  core @0.000682> loading Dancer::Handler::PSGI handler in /usr/local/share/perl5/Dancer/Handler.pm l. 45
[25947]  core @0.003442> loading handler 'Dancer::Handler::PSGI' in /usr/local/share/perl5/Dancer.pm l. 474
[25947]  core @0.004753> add middleware Debug in /usr/local/share/perl5/Dancer/Handler/PSGI.pm l. 76
Odd number of elements in anonymous hash at /usr/local/share/perl5/Plack/Middleware.pm line 14.

#perl -v
This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi

# starman -v
Starman 0.3003



#cat app1.pl
use Dancer;
use Test;
Dancer->dance;

# cat Test.pm
package Test;
use strict;
use Dancer ':syntax';    
get '/robots.txt' => sub {
        return "User-agent: *\nDisallow: /";
};
@bigpresh
PerlDancer member

Interesting - are you loading any Plack middlewares?

@gecon

Oh yes! This is from the development.yml:

plack_middlewares:
  -
    - Debug
    - JSON::ForBrowsers
    - panels
    -
      - Parameters
      - Memory

Thank you!

@yanick

Aaah, got it. The config simply has to be

plack_middlewares:
  -
    - Debug
    - JSON::ForBrowsers
    -
    - panels
    -
      - Parameters
      - Memory

or

plack_middlewares:
  -
    - Debug

    - panels
    -
      - Parameters
      - Memory
  -
    - JSON::ForBrowsers
    -

Dancer::Cookbook explains it: the first item of the list is the name of the plugin, and the following are the arguments passed to it. So in your original config, you were calling 'Debug' with the arguments 'J::FB', 'panels' and 'ARRAYREF'. Hence the odd number.

@yanick yanick closed this Jul 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment