Debugging Perl

Problem

You have an error in your Perl script and want to debug it.



Solution

Debugging in Perl is very extensive, this demo is very basic! 🙂 Check the reference for further instruction.

You can manipulate PERLDB_OPTS variable, to force some debugging – then just pass through a -d option to your perl script.

Also system debugging is at the reference tab.



Example


export PERLDB_OPTS="NonStop frame=1 AutoTrace"

perl -d -pi'.bak' -e 's/unix/UNIX/g' *htm*

Output:

Package -e.
0: BEGIN { require 'perl5db.pl' };LINE: while () {
1: s/unix/UNIX/g
0: BEGIN { require 'perl5db.pl' };LINE: while () {
1: s/unix/UNIX/g
0: BEGIN { require 'perl5db.pl' };LINE: while () {
1: s/unix/UNIX/g
0: BEGIN { require 'perl5db.pl' };LINE: while () {
1: s/unix/UNIX/g
0: BEGIN { require 'perl5db.pl' };LINE: while () {
1: s/unix/UNIX/g
0: BEGIN { require 'perl5db.pl' };LINE: while () {
1: s/unix/UNIX/g
0: BEGIN { require 'perl5db.pl' };LINE: while () {
1: s/unix/UNIX/g
0: BEGIN { require 'perl5db.pl' };LINE: while () {
1: s/unix/UNIX/g
0: BEGIN { require 'perl5db.pl' };LINE: while () {
1: s/unix/UNIX/g
0: BEGIN { require 'perl5db.pl' };LINE: while () {
1: s/unix/UNIX/g
0: BEGIN { require 'perl5db.pl' };LINE: while () {
1: s/unix/UNIX/g
0: BEGIN { require 'perl5db.pl' };LINE: while () {
1: s/unix/UNIX/g
0: BEGIN { require 'perl5db.pl' };LINE: while () {
entering Config::DESTROY
entering IO::Handle::DESTROY
entering IO::Handle::DESTROY



Reference

[tags]Debugging Perl, Perl Coding School[/tags]



Leave a Reply

Your email address will not be published. Required fields are marked *