Search code examples
perlperldoc

How to find (offline) perl documentation - "case insensitive" or with regular expression


How do I get information from perldoc (offline) when I don't know the exact syntax?

For example, when searching for the "lwp" module, it's not sufficient to look for perldoc -m lwp or perldoc -m lwp::simple (in linux/unix).
As a beginner I would think, perl would provide something like perldoc -m /lwp/ to search for the explression.
But you have to find out the exact syntax of the module, and then you can search for the documentation (or, you would write a oneliner/grep to search all the pod files for the expression) - but sometimes I don't remember the exact syntax and need a hint.

Do I miss something?
Searching the faq can be done with an expression perldoc -q something but not anything else (-f / -m / ...) ? Thank you, for your support.

Update:
- Windows: (by its case-insensitive nature) one can run perldoc [-m] lwp::simple and will find LWP::Simple
- Linux/Unix: perldoc has an -i Parameter for insensitive search. (see perldoc -h)
Running perldoc -i [-m] lwp::simple will find LWP::Simple

(the -m Parameter displays the module code and plaintext POD documentation - one can leave it, because it's not that pretty)


Solution

  • By exact syntax, do you mean the name of the module? Why are you looking for documentation for a module you don't know the name of?

    If you want to find some module names installed locally, cpan(1) will give you the list:

     % cpan -l
    

    From that, you can search a name all you like (as you mentioned):

     % cpan -l | grep -i lwp
    

    This follows the basic unix idea of reusing tools that already do a good job. cpan give you the list and grep searches it.

    In that list would be LWP. Since module names are case sensitive, you have to use the proper case (although some case-insensitive file systems fake this for you):

     % perldoc LWP
    

    Mostly, I get the name of the module I want to read about because it's noted in source code or I'm using an object of that type. I take the names from that:

    print "The object is of type: ", ref $obj;
    

    Beyond that, there is current work (discussed this week at The Perl Conference) to index various types of data and let you search for them.