tags:

views:

460

answers:

7

I find from reading perldoc perlvar, about a thousand lines in is help for %ENV. Is there a way to find that from the command line directly?

On my Windows machine, I've tried the following

perldoc ENV
perldoc %ENV
perldoc %%ENV
perldoc -r ENV (returns info about Use Env)
perldoc -r %ENV
perldoc -r %%%ENV
perldoc -r %%%%ENV (says No documentation found for "%ENV")

None actually return information about the %ENV variable.

How do I use perldoc to find out about %ENV, if I don't want to have to eye-grep through thousands of line?

I've tried the suggested "perldoc perlvar" and then typing /%ENV, but nothing happens.

perl -v: This is perl, v5.8.0 built for MSWin32-x86-multi-thread

Though I've asked about %ENV, this also applies to any general term, so knowing that %ENV is in perlvar for this one example won't help me next time when I don't know which section.

Is there a way to get perldoc to dump everything (ugh) and I can grep the output?

A: 

If you'd like to see the contents of your %ENV, you can use Data::Dumper to print it out in a rather readable format:

perl -MData::Dumper -e 'print Dumper \%ENV'

amoore
I'm well versed in how to see the contents of %ENV, what I want is how to get the perl help, for example %ENV says "The hash %ENV contains your current environment." Not just %ENV, but for any generally needed help.
piCookie
+2  A: 

The searching for %ENV is a feature of the pager named 'less', not of perldoc. So if perldoc uses a different pager, this might not work.

Activestate Perl comes with HTML documentation, you can open perlvar in your browser, hit Ctrl+f and type %ENV, then hit enter.

moritz
+3  A: 

perldoc doesn't have an option to search for a particular entry in perlvar (like -f does for perlfunc). General searching is dependent on your pager (specified in the PAGER environment variable). Personally, I like "less." You can get less for windows from the GnuWin32 project.

Michael Carman
Actually, it's had this option for a while, but it's from a patch I submitted. It's only in the latest development version (see my reply for details) which is why you probably didn't see it.
Ovid
I never knew about the pager variable. That helps me a HUGE amount. Thanks!
piCookie
A: 
  1. Install unixutils for Windows (http://unxutils.sourceforge.net/)
  2. Call: perldoc perlvar | grep -A10 %env
Eli Bendersky
+19  A: 

Check out the latest development version of Pod::Perldoc. I submitted a patch which lets you do this:

$ perldoc -v '%ENV'

%ENV
$ENV{expr}
The hash %ENV contains your current environment. Setting a value in
"ENV" changes the environment for any child processes you subsequently
fork() off.
Ovid
Ooh. That's a nice addition. I'll have to check that out.
Michael Carman
Huh, that must mean that perldoc doesn't have a switch to tell you its version. You get the version just with `perldoc`, but once you mention "latest development version", I wondered how I would find out which version I had.
brian d foy
A: 
firefox http://perldoc.perl.org/perlvar.html#%ENV

By the way, many many many bugs have been fixed since 5.8.0.

ysth
+1  A: 
brian d foy