[Israel.pm] Problem with the perl debugger

Peter Gordon peter at pg-consultants.com
Thu Mar 4 03:39:57 PST 2010

Here is a bit of code with an error $var has not been defined

#! /usr/bin/perl 

use strict ;
use warnings ; 

$var = 42 ; 

Run the above code with the debugger:

perl -d test.pl

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

BEGIN not safe after errors--compilation aborted
at /usr/share/perl/5.10/Carp/Heavy.pm line 5.
Compilation failed in require at /usr/share/perl/5.10/Carp.pm line 33.
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.  

Running perl test.pl (without the debugger) gives
Global symbol "$var" requires explicit package name at /dev/shm/test.pl
line 6.
Execution of /dev/shm/test.pl aborted due to compilation errors.

The following code produces the correct error with the debugger.

#! /usr/bin/perl 

use strict ;
use warnings ; 
use Carp::Heavy ;
$var = 42 ; 

Why can't the debugger get it right?


More information about the Perl mailing list