s_m
s_m

Reputation: 129

Is it possible to enable autocomplete in perl debuging using perl -d?

I am debugging Perl using perl -d in Windows. I am looking for auto-complete feature because I have to set breakpoint in other files, many times, which may contain long-folder-name. I wandering where I can set/enable auto-complete for perl -d?

perl -d script.pl

DB<1> f sub_folder1\sub_folder2\sub_folder3\file.pm <- need auto-complete here

Upvotes: 1

Views: 368

Answers (2)

Will
Will

Reputation: 94

It's possible to have a basic form of auto completion under perl -d by installing the PadWalker module, per https://perldoc.perl.org/perldebug.html:

A rudimentary command-line completion is also available, including lexical variables in the current scope if the PadWalker module is installed.

It doesn't work for things like method names, but it means you can type $s<Tab> rather than $some_variable_with_a_long_name for variables in the current scope.

Upvotes: 0

xxfelixxx
xxfelixxx

Reputation: 6602

If you type x \%INC you will see the full list of included files, which you can grep, as in:

  DB<6> x \%INC
0  HASH(0x1a8e960)
   'Carp.pm' => '/usr/share/perl5/vendor_perl/Carp.pm'
   'Config.pm' => '/usr/lib64/perl5/Config.pm'
   'Config_git.pl' => '/usr/lib64/perl5/Config_git.pl'
   'Config_heavy.pl' => '/usr/lib64/perl5/Config_heavy.pl'
   'Data/Dumper.pm' => '/usr/lib64/perl5/vendor_perl/Data/Dumper.pm'
   'Exporter.pm' => '/usr/share/perl5/vendor_perl/Exporter.pm'
   ....

The perl debugger does not have auto-complete built in, however you can get auto-complete for free by running the debugger through an IDE. I use emacs for this (M-x perldb), and it easily handles file autocompletion, as well as showing a pointer to the code as you step through it.

According to the help inside the debugger, you can use partial filenames or a regex to lessen the typing:

DB<1> h f
f filename    Switch to viewing filename. File must be already loaded.
        filename may be either the full name of the file, or a regular
        expression matching the full file name:
        f /home/me/foo.pl and f oo\. may access the same file.
        Evals (with saved bodies) are considered to be filenames:
        f (eval 7) and f eval 7\b access the body of the 7th eval
        (in the order of execution).

Here is an example:

DB<3> f Dumper.pm
Choosing /usr/lib64/perl5/vendor_perl/Data/Dumper.pm matching 'Dumper.pm':

Upvotes: 4

Related Questions