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

Avast PerlMonks!

While we all know that perldoc will render the masterpieces that dwell in tagged areas. Is there some super perldoc one-liner that will pull out a specific function|name|whatever from a personally made module or proggie?

So far as I can tell, the answer is no (UPDATE: can anybody confirm this). It would be wicked fantastic to type a one liner like this perldoc -tT huh.pl whatThe and get the comments for the subroutine "whatThe" back; which... for the following program is " This subroutine does nothing (yay)."

#!/usr/bin/perl use strict; =head1 NAME Huh.pl =cut =head1 DESCRIPTION Yeah, I dunno. =cut use strict; my $now = 0; whatThe(); exit($now); ############################### =head1 SUBROUTINES =item whatThe This subroutine does nothing (yay). =cut # best mysterious sub ever sub whatThe { #yawn } =back =head1 SEE ALSO sleep(-_-)z Z

Replies are listed 'Best First'.
Re: Perldoc question for the monastary.
by jdporter (Paladin) on Nov 06, 2007 at 00:52 UTC

    You're asking for a module? Where are all the modules? Did you check CPAN? As it happens, there's a plethora of Pod modules there.

    Ones which look (to me) promising for this problem are Pod::Index and Pod::Select.

    A word spoken in Mind will reach its own level, in the objective world, by its own weight

      True, those modules are promising, but I suppose this means I'll have to write my own script to rip out the data and that such functionality isn't built-into any perldoc command line attribute.

      Update: Using Pod::Select, the one-liner could be this

      perl -e 'use Pod::Select; podselect({-sections =>[$ARGV[1]]},($ARGV[0]))' huh.pl whatThe
Re: Perldoc question for the monastary.
by Intrepid (Curate) on Nov 06, 2007 at 07:43 UTC

    I'll just observe that by asking for a super perldoc one-liner, it sounds to me as if the OP is asking for a feature that would be built in to Perl or one of the core modules; something that would perhaps exploit a "bound relationship" between a "tagged area" and a subroutine. However, there is no such relationship under Perl. My first thought is that the OP comes from Python and is therefore familiar with Python's docstring data. docstring makes a brief bit of function / subroutine documentation a part of a function object, a member, that is. Perl doesn't have that.

      That would be correct. I was looking for, not a cpan package , but an already implemented command line; or at least confirm that it doesn't exist.

      Perldoc modules definately go the distance and implement some of the functionality bereft of the command line tool and of course make it easier to write a wrapper around perldoc (which is what I was trying to avoid).

      There are so many ways to do any one thing in perl, so I thought it a good idea to ask before giving up and wrapping. I should have phrased my question "(o_O) Is it really NOT implemented in perldoc already !?".

      *grumbles* python? lol; heretic!