[Chicago-talk] chown inside a script
Jay Strauss
me at heyjay.com
Thu Dec 6 17:54:10 PST 2007
On Dec 6, 2007 6:41 PM, Brian Katzung <briank at kappacs.com> wrote:
> Jay,
>
> Here's a rough code snippet to get you started.
>
> use File::Find;
>
> # Queue looks like /some/path/closed/user_name/file_name
> my $base_dir = '/some/path/closed';
>
> sub proc_files
> {
> return unless (-f $File::Find::name &&
> $File::Find::name =~ m{^\Q$base_dir\E/([^/]+)/([^/]+)$});
>
> my ($user, $file) = ($1, $2);
> print "Process file $file in queue for user $user\n";
> }
>
> find({ 'wanted' => \&proc_files, 'follow' => 0, 'no_chdir' => 1 },
> $basedir);
>
> - Brian
Thanks Brian, I'm not exactly sure what the regex does. I don't know
wher \Q and \E do, the other part I think is match and remember the
directory and filename.
Also, I already know where the files are, what's the advantage of
using File::Find?
Jay
More information about the Chicago-talk
mailing list