"Chas. Owens" <chas.ow...@gmail.com> writes: > On Fri, Jun 19, 2009 at 09:35, Harry Putnam<rea...@newsguy.com> 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" > );
Does something else need to be done at "/directory/to/chown"? Or maybe I'm managing to get something wrong even in that short code. (Note I've tried adding a semi-colon at that line but doesn't help) #!/usr/local/bin/perl use strict; use warnings; use File::Find; my $uid = '1001'; my $gid = '1005'; find( sub { chown $gid, $uid, $_ or die "could not chown '$_': $!"; } "/cvsbX/" ); outputs: String found where operator expected at ./chown line 14, near ""/cvsbX/"" (Missing semicolon on previous line?) syntax error at ./chown line 14, near ""/cvsbX/"" Execution of ./chown aborted due to compilation errors. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/