Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Statement 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0

I am curious to know how this statement works???
[tt]
find ( { wanted => \&change, no_chdir => 1}, @dirs );
[/tt]

I understand change is the subroutine but not sure about the rest of it?
wanted => ?
no_chdir ?
=> 1 ?
@dirs ?

Can you explain each word and symbol??
 
wanted and no_chdir are parameters that the find command (actually an ordinary subroutine) uses

wanted is set to \&change and no_chdir is set to 1

@dirs is an array, I would guess that it's an array of directories Mike
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Thanks,
Final question i promise....
wHY is no_chdir set to 1. What does the number 1 represent??
 
Hi again,

I just looked at the documentation and it says that setting no_chdir to 1 means that find doesn't change directory into each directory it's working with. So that means your wanted function (&change in your example) would need to understand this.

The documentation for File::Find is quite good - on my system it's at file://C:\Perl\html\lib\File\Find.html and you can also view it from the command line using:

perldoc File::Find Mike
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Well, I've never used this function, but from looking at it, this is my best explanation.

find(...) is a function. Everything inside are arguments.

=> implies hash pair. So, wanted => \&change, no_chdir => 1, are hash pairs.

@dirs is an array.

I'm not sure why "wanted" & "no_chdir" are in {}.

Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top