best way to search perldocs

W

wana

I was disconnected from the internet and had no access to my books
today, but I did have access to all of the perldocs saved on my
computer to look through. I was trying to find a way to change pwd
from a script.

I just wanted to write the most simple little thing to change
directories and list the contents. I never really learned shell
programming and I like to try to do everything with Perl these days.

Once I reconnected, I instantly found chdir with a simple Google
search. I wish I had Google to look through my perldocs though.

Question: How could I have found this command more easily in perldocs?
I was going crazy grepping through perltoc hopelessly to the point
where I was sure that there was no way to do it. By the way, why
doesn't system("cd $ARGV[0]") work?

Thanks!
 
P

Paul Lalli

wana said:
I was disconnected from the internet and had no access to my books
today, but I did have access to all of the perldocs saved on my
computer to look through. I was trying to find a way to change pwd
from a script.

I just wanted to write the most simple little thing to change
directories and list the contents. I never really learned shell
programming and I like to try to do everything with Perl these days.

Once I reconnected, I instantly found chdir with a simple Google
search. I wish I had Google to look through my perldocs though.

Question: How could I have found this command more easily in perldocs?
I was going crazy grepping through perltoc hopelessly to the point
where I was sure that there was no way to do it. By the way, why
doesn't system("cd $ARGV[0]") work?

perldoc perlfunc
"Functions sorted by category". Find one that looks likely, and then do
perldoc -f <function>
to read about it.

Paul Lalli
 
R

Robert Gamble

I was disconnected from the internet and had no access to my books
today, but I did have access to all of the perldocs saved on my computer
to look through. I was trying to find a way to change pwd from a
script.

I just wanted to write the most simple little thing to change
directories and list the contents. I never really learned shell
programming and I like to try to do everything with Perl these days.

Once I reconnected, I instantly found chdir with a simple Google search.
I wish I had Google to look through my perldocs though.

Question: How could I have found this command more easily in perldocs?
I was going crazy grepping through perltoc hopelessly to the point
where I was sure that there was no way to do it.

pdldoc provides apropos-like searching of the perldocs.
By the way, why doesn't system("cd $ARGV[0]") work?

What happens here is a child process is created to run a shell which in
turn runs your cd command. The shell then exits and control is returned
to your program. Changing the working directory of a child process does
not affect the working directory of the parent process.

Rob Gamble
 
J

Jürgen Exner

wana said:
I was disconnected from the internet and had no access to my books
today, but I did have access to all of the perldocs saved on my
computer to look through. I was trying to find a way to change pwd
from a script.

perldoc -q password
I just wanted to write the most simple little thing to change
directories and list the contents. I never really learned shell
programming and I like to try to do everything with Perl these days.

Once I reconnected, I instantly found chdir with a simple Google
search. I wish I had Google to look through my perldocs though.

Question: How could I have found this command more easily in perldocs?

"perldoc perlfunc" lists all Perl functions by category. The section for
"Functions for filehandles, files, or directories" contains chdir.
I was going crazy grepping through perltoc hopelessly to the point
where I was sure that there was no way to do it. By the way, why
doesn't system("cd $ARGV[0]") work?

It does work perfectly fine, although it probably doesn't do what you
mistakenly expect it to do. Details see
perldoc -q modified
which by the way has nothing to do with Perl but with basic process
security.
 
J

Joe Smith

wana said:
Once I reconnected, I instantly found chdir with a simple Google search
Question: How could I have found this command more easily in perldocs?

When learning a language like Perl, one should always look over the
list of built-in functions at least once, even if just a cursory glance.

It is not expected that a beginner memorize all the functions listed
in perlfunc (or listed in an appendix in a book), but the novice is
expected to know that a list of functions exists.
-Joe
 
M

Malcolm Dew-Jones

wana ([email protected]) wrote:

: Question: How could I have found this command more easily in perldocs?

I use grep, find, or perl itself, to search through the pods.

On this computer, I found the perldocs as follows

C:> cd perl
C:\perl> dir /s/b *.pod

on linux, when all else fails, do a "find / -name \*pod"

On dos you can search multiple files using for.

for %i in (*.pod) do perl -ne "print if m/whatever/" %i


$0.02
 
C

Chris Mattern

wana said:
where I was sure that there was no way to do it. By the way, why
doesn't system("cd $ARGV[0]") work?

Because system spawns a child process. You made a child process
which changed its working directory and then promptly terminated.
This did not, of course, change the working directory of the
*parent* process, your perl program.

--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top