4

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?

mpapec
  • 50,217
  • 8
  • 67
  • 127
piCookie
  • 9,640
  • 2
  • 19
  • 19

7 Answers7

20

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
  • 11,580
  • 9
  • 46
  • 76
  • Ooh. That's a nice addition. I'll have to check that out. – Michael Carman Sep 17 '08 at 16:47
  • 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 Sep 20 '08 at 20:54
3

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
  • 30,628
  • 10
  • 74
  • 122
  • 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 Sep 17 '08 at 15:59
  • I never knew about the pager variable. That helps me a HUGE amount. Thanks! – piCookie Sep 17 '08 at 16:22
2

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
  • 12,710
  • 1
  • 41
  • 63
1

I use Apache::Perldoc (old, but still does its job) on my local machine to browse the local documentation. If I have net access though, I just look at perldoc.perl.org and search. However, in this case, search isn't useful for the variables and it's better to use the Special variables link at the left of the page.

As you get more experience with Perl, you'll know where to look for the documentation. For know, you might have to refer to perltoc, but after awhile you'll know to look for functions in perlfunc, variables in perlvar, and so on.

You might also use my Perl documentation documentation.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
0
  1. Install unixutils for Windows
  2. Call: perldoc perlvar | grep -A10 %env
Apurv
  • 3,723
  • 3
  • 30
  • 51
Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
0
firefox http://perldoc.perl.org/perlvar.html#%ENV

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

ysth
  • 96,171
  • 6
  • 121
  • 214
-1

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
  • 445
  • 2
  • 4
  • 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 Sep 17 '08 at 15:54