LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   RTFM ? Where is TFM? (http://www.linuxquestions.org/questions/linux-general-1/rtfm-where-is-tfm-497825/)

cyb0rg777 11-02-2006 05:03 AM

RTFM ? Where is TFM?
 
Simple question.I was trying to learn some perl and I need to know what library to use so I searched the web and found which libraries to use.Now I download the libraries and more man page documentation.I have the manuals somewhere on my system so I look all over for filenames similar to what I want.I spent almost an hour trying to find the manual that I could have spent RTFM .OK ,since I needed two modules I now need to find the second man page.Same problem,I learned nothing about how to find TFM.

What is the easiest way to find TFM?

matthewg42 11-02-2006 06:32 AM

perl comes with it's own documentation tool, perldoc, although it's usual for regular manual pages to be generated and installed as well.

perldoc can be used to search for perl-specific documentation on your system. For example, to see the docs for HTML::Parser, you can just enter
Code:

perldoc HTML::Parser
You can also search for specific perl built-in functions, like this:
Code:

perldoc -f stat
Or you can search for keywords from the perl FAQ like this:
Code:

perldoc -q JAPH
If all that fails, look at the .pm module files themselves or .pod files in the same directory as the .pm files - they may contain pod tags which you can turn into a nice readable form using perldoc on the file, like this:
Code:

perldoc /usr/lib/perl5/HTML/Parser.pm

cyb0rg777 11-02-2006 07:15 AM

Very helpful stuff there .I was looking for the ncurses perl module info .I don't even know what function are inside it.I used locate command because thats what I always us eto find files.I tried a bunch of searches.
locate perl-curses
locate perl-ncurse
locate curses
locate ncurses-perl
I finally found the man page named Curses ,with a capital C.How could I have saved all that time.I'm still looking for a network module www-perl or something like that.What is the quickest way to find it ,Please.

If there is a way to do it for man pages that would be very helpful because I use c sometimes too and I need to look up libraries and functions for c.

matthewg42 11-02-2006 08:13 AM

The short answer is that you have to know about the perl module naming scheme, which isn't very helpful.

Once you know that case comes into it, it's helpful to know that locate has an option -i, which makes it search in case-insensitive mode.

perldoc also has an option to turn off case sensitivity, also -i, and so does man.

The problem with all these methods is that you might not have the required module installed, in which case you won't find anything on your machine.

I would use two ways to search for modules which I don't have installed:
  1. My Linux distro's package management system. I use Ubuntu, so I can search the package system using a command like this:
    Code:

    apt-cache search perl |grep -i curses
    Distros with other package managers will have some similar search method.
  2. The CPAN website is probably the definitive site for finding out about perl modules. The modules search feature is very helpful. Once you know the module name, finding the documentation should be pretty straight forward.

cyb0rg777 11-02-2006 08:19 PM

I found this perl script in the faq to find your .pm files.

Code:

#! /usr/bin/perl
use File::Find;
my @files;
find sub { push @files, $File::Find::name if -f _ && /\.pm$/ },
@INC;
print join "\n", @files;
print "\n";

It finds all my files but i still can't tell what they are.The library I was looking for was libwww-perl ,but the module file was named LWP.pm .So it was on the list but I didn't know what it was.I think I have just found a project I can work on to help me learn perl.To build an index of all man pages and search though them.Too bad they are in gz format it will make them harder to search.

matthewg42 11-02-2006 09:05 PM

That perl script does more or less the same as this command from the shell:

Code:

find / -name \*.pm
...which is a little easier, but like we say in perl land, TMTOWTDI (there's more than one way to do it).

Opening .gz files is easy in perl - no need to unzip the files and re-zip them when you're done. You can open them like this:

Code:

open(MYGZFILE, "gunzip -c $filename|") || die "can't open $filename with gunzip: $!";
while (<MYGZFILE>) {
    print "Line from compressed file: $_";
}
close(MYGZFILE);

Perl is the best :D


All times are GMT -5. The time now is 07:18 PM.