Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Beginners guide to File::Find

by dwhite20899 (Friar)
on Aug 07, 2005 at 00:50 UTC ( #481587=note: print w/ replies, xml ) Need Help??


in reply to Re: Beginners guide to File::Find
in thread Beginners guide to File::Find

If I have a need to process all of the files in a directory tree, I use find2perl to generate a template. If you are familiar with the *ix find command, there are several options you can use to your advantage, but I usually stick to find2perl / -type f -print > template.pl . You can substitute any starting directory instead of / to suit, and the -type f will limit the code to files.

You should end up with this subroutine:

sub wanted { my ($dev,$ino,$mode,$nlink,$uid,$gid); (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && -f _ && print("$name\n"); }

I replace the print("$name\n") with my code that performs an action on every file.


Comment on Re^2: Beginners guide to File::Find
Select or Download Code
Replies are listed 'Best First'.
Re^3: Beginners guide to File::Find
by Anonymous Monk on Dec 07, 2011 at 19:57 UTC

    Does anyone know how to get the return value for find ? There is no documentation or any discussion on it

      According to the source, the find function does not have a (meaningful) return value.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://481587]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2015-07-28 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (252 votes), past polls