Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

[perldebugger] calling perldoc from within the debugger

by LanX (Saint)
on Aug 06, 2009 at 12:22 UTC ( #786405=perlquestion: print w/replies, xml ) Need Help??

LanX has asked for the wisdom of the Perl Monks concerning the following question:

I was pleased to see that the debugger supports calling perldoc and was very surprised that perldoc -h produced a totally different helppage with plenty of new options, including to call a html-version in a browser... (didn't work, but thats another story...)

wellllllll ... it turned out that this was actually the help-page of man and that perldoc is just an alias to man.

This implies that typical options like perldoc -f doesn't work!

lanx@nc10-ubuntu:~$ perl -de0

... main::(-e:1): 0

DB<1> perldoc -f grep

grep (1) - print lines matching a pattern

DB<2>

as you easily see thats the ouput of "man -f print" perldebug says: "On systems traditionally bereft of a usable man command, the debugger invokes perldoc. "

hmm OK, my ubuntu has man, but how can I make it call perldoc with all options enabled???

Cheers Rolf

UPDATE: Is it possible to realize and automatically enable a command doc within the debugger which calls a shellscript doc which I can config as a wrapper to do what I want?

(Delegating to a shellscript would allow me to use the same syntax from the shell as from within the debugger...)

Replies are listed 'Best First'.
Re: [perldebugger] calling perldoc from within the debugger
by broomduster (Priest) on Aug 06, 2009 at 13:06 UTC
    Does $DB::doccmd='perldoc' do what you want? Seems to work OK for me with 5.10.0:
    -> perl -de0 main::(-e:1): 0 DB<1> $DB::doccmd='perldoc' DB<2> perldoc -f grep
    shows me the usual perldoc -f grep output
      Thanks!

      And I just figured out how to preset aliases at startup.

      There is a ini-file called .perldb sourced!

      lanx@nc10-ubuntu:~$ cat .perldb sub afterinit { $DB::alias{ALIAS}='s/ALIAS/command/' }

      so with your approach I may write

      sub afterinit { $DB::doccmd='perldoc'; $DB::alias{doc}='s/doc/perldoc/'; }

      so now I can type:

      DB<2> doc -f print

      and get better results...

      ... now I just have to figure out the best way to call a shellscript called doc, such that I have the same syntax from shellprompt (and than I can enrich the features of perldoc for my needs 8)

      lanx@nc10-ubuntu:~$ doc -k '=='

      Cheers Rolf

        You might look at Devel::Command, which I wrote when I needed to add commands to the debugger.

        It's a bit of a hack, as it has to monkeypatch DB::DB with a version that has a Module::Pluggable command loader. A very small command module that just system()s the shell command you want may do it.

Re: [perldebugger] calling perldoc from within the debugger
by doom (Deacon) on Aug 07, 2009 at 21:15 UTC

    Myself, I've never run into this issue, because I work inside of emacs normally (where you can run the perl debugger with Alt-x perldb), and I keep this cperl function bound to a key: (cperl-perldoc-at-point)

    That does the equivalent of a "perldoc -f" on whatever function the cursor is pointing at.

      Actually I'm working a lot within emacs and sepia, but when I'm testing and posting stuff for the monastery I'm trying to do it in the more generally known debugger.

      And how to extend the debugger is always nice to know... 8)

      Cheers Rolf

        "Actually I'm working a lot within emacs and sepia,"... ah, can I take this opportunity to shill for a discussion group I'm trying to get going about emacs/perl issues?

        emacs-perl intersection

        (I've actually got some basic questions about sepia I'd like to get answered one of these days...)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://786405]
Approved by marto
Front-paged by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2023-12-08 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (37 votes). Check out past polls.

    Notices?