Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Question about Perl man pages

by bartonski (Initiate)
on Jul 07, 2010 at 03:34 UTC ( [id://848376]=perlquestion: print w/replies, xml ) Need Help??

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

According to Programming Perl, 3rd ed, "You can search individual man pages by using the name of the manpage as the command and passing a Perl regular expression as the search pattern:
% perlop comma % perlfunc split
..." This is supposedly available on perl 5.6.1. I tried this on my Debian Etch box, using perl v5.8.8, but when I run $ perlfunc split, I get the following error: -bash: perlfunc: command not found Is this a matter of how debian packages Perl? I tried searching the file system for perlop:
$ locate perlfunc /usr/share/man/man1/perlfunc.1.gz /usr/share/perl/5.8.8/pod/perlfunc.pod
Neither of these is executable.

Replies are listed 'Best First'.
Re: Question about Perl man pages
by cdarke (Prior) on Jul 07, 2010 at 07:03 UTC
    perldoc -f split, assuming that perldoc is in a directory which is in your PATH.

    You can always setup an alias, in bash:
    alias "perlfunc=perldoc -f" perlfunc split
    As others have said, it is also the name of a man page, as in man perlfunc
Re: Question about Perl man pages
by biohisham (Priest) on Jul 07, 2010 at 04:42 UTC
    %perldoc perlop comma
    since perldoc is the command that runs a program which looks for .pod format information and it accepts switches like perlop, perlfunc...etc whereas it appears that you are using a switch that your system terminal is interpreting as a command when it says -bash: perlfunc: command not found...

    Also read %perldoc perldoc.

    Update: On a deeper inspection, I advice you, I agree with bartonski that perldoc would seek to find the manpages for both perlop and comma together, heed cdarke's reply.. Using the -f, -q ...etc switches is my fav method checking the docs on my XP machine...

    I am interested at finding more about the OS differences when it comes to accessing the documentation and whether the Camel book has really meant that the OP's original query was possible on an OS different from the Debian or XP as I feel intrigued too..


    Excellence is an Endeavor of Persistence. A Year-Old Monk :D .

      The implication in Programming Perl is that 'perlop', 'perlfunc', etc. are directly executable, not run as arguments to perldoc.

      Furthermore,
      $ perldoc perlop comma No documentation found for "comma".

      ... i.e. perldoc is trying to display the man pages for both 'perlop' and 'comma'.

      perldoc -f works fine, and I'll probably use the alias suggested by cdarke.

      I'm simply curious about why 'Programming Perl' says that I can search perl man pages using the name of the man page and a Perl regular expression, and then I can't.

      As irrational as it sounds, I feel a little cheated... that seemed like a nice little shortcut, and I'm disappointed that the Camel book has led me to a non-existent feature.

Re: Question about Perl man pages
by afoken (Chancellor) on Jul 07, 2010 at 04:06 UTC

    Either someone has accidentally removed the perlfunc script, or this is a Debian bug. Some time ago, the Debian people decided that the perl documentation does not contain a sufficient license disclaimer, and so they removed the perl documentation from the perl package. Maybe your Debian version is affected. In that case, search for a perl documentation package.

    Update: Nonsense, I mixed up perlfunc and perldoc. Sorry.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: Question about Perl man pages
by Khen1950fx (Canon) on Jul 08, 2010 at 10:48 UTC
    You can use perldoc -f for functions and perldoc -v for variables, but there's no similar switch for operators. What you could do is to use this time to learn operators. Sometimes, I use Term::Shell as a personal notebook mechanism. Instead of making postit notes, I write a few subs using my notes. I put together a sample that can get you going. I started with comma, but as you progress, just add a sub for each operator.
    package perlop; use base qw(Term::Shell); my $obj = perlop->new(); $obj->cmdloop; use strict; use warnings; sub prompt_str { my $cwd = 'cwd'; $cwd =~ s[^\Q$ENV{HOME}\E][~]; "perlop> "; } sub run_comma { print <<"EOF"; Binary "," is the comma operator. In scalar context it evaluates its l +eft argument, throws that value away, then evaluates its right argume +nt and returns that value. This is just like C's comma operator. In list context, it's just the list argument separator, and inserts bo +th its arguments into the list. These arguments are also evaluated fr +om left to right. The => operator is a synonym for the comma except that it causes its l +eft operand to be interpreted as a string if it begins with a letter +or underscore and is composed only of letters, digits and underscores +. This includes operands that might otherwise be interpreted as opera +tors, constants, single number v-strings or function calls. If in dou +bt about this behaviour, the left operand can be quoted explicitly. Otherwise, the => operator behaves exactly as the comma operator or li +st argument separator, according to context. EOF print "\n"; }
      but there's no similar switch for operators.
      At the last YAPC::NA, there was a lightning talk from someone who's rewriting perlop so each operator gets its own section (currently many operators are grouped together, for instance +=, |=, >>=, etc). Once that work is done, adding another flag to perldoc to search for an operator would not be hard to implement.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-04-19 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found