On Fri, Jun 19, 2009 at 09:35, Harry Putnam<[email protected]> wrote:
> How to manage a recursive chown using perl function chown?
>
> Do I have to employ something like File::Find to recursively chown a
> directory heirarchy.  Or maybe opendir and readdir...
>
> Or is there some simpler way?
snip

Whenever you want to walk a directory tree you should think of [File::Find][1]:

find(
    sub {
        chown 100, 100, $_
            or die "could not chown '$_': $!";
    }
    "/directory/to/chown"
);

The find function will run the coderef in the first argument for every
file and directory in /directory/to/chown.  The current filename will
be in $_ (if you want access to the full path to filename you can use
$File::Find::name).

[1] : http://perldoc.perl.org/File/Find.html


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to