CPAN seems to struggle with out of memory errors on the default Debian distribution. To get around this, you could try CPANMinus.
sudo apt-get install curl
curl -L http://cpanmin.us | perl - --sudo App::cpanminus sudo cpanm -i <Module Name>
Dancer To get Dancer working with CPANminus
sudo cpanm -i Dancer