Basic debugger concept #1: the built in Perl debugger referenced above will not work unless your program compiles. So if you have major flaws in your code, the built-in Perl debugger is useless. So as a first step, be sure you:
use strict;
use diagnostics;
and to call Perl using the '-w' (warnings) switch.