ban
ban

Reputation: 685

How to create a Perl debugger

I wrote a bunch of functions for the Perl debugger, but every time I want to test them I need to do export PERL5DB="my code". Is there a way I can set it to a file and then use it?

I tried adding a file myperldb.pl in /usr/lib/perl/, but it doesn't allow me. That's because I am not the administrator user. So is there a workaround to it?

Upvotes: 2

Views: 97

Answers (3)

Eugen Konkov
Eugen Konkov

Reputation: 25282

You may use this command:

PERL5DB="BEGIN{ require 'my_debugger.pm' }" perl -d script.pl

$cat my_debugger.pm
package DB;

sub DB {
}

sub sub {
        print "$DB::sub called\n";

        return &$DB::sub;
}


1;

You may find more information here.

Upvotes: 0

daxim
daxim

Reputation: 39158

That's what the .perldb file is for.

Upvotes: 2

mob
mob

Reputation: 118695

Make a copy of /usr/lib/perl/perl5db.pl in some other directory, change it to your heart's content, and debug your scripts with

perl -I/dir/that/contains/your/perl5db.pl/copy/ -d your_script.pl

The -I<dir> switch will get perl to look in the directory you choose to find libraries before it looks in its default directories.

Upvotes: 4

Related Questions