skyler has asked for the wisdom of the Perl Monks concerning the following question:
#! perl use strict; use File::Copy; use File::Find; no warnings 'File::Find'; my $infile = "c:\\doclist1.chr"; my @directories; # first lets build our directory list open IN, "<$infile" or die "Couldn't open $infile, $!"; while (<IN>) { chomp; my @fields = split /,/; my $path_str = $fields[6]; do { warn "Empty field 7"; next } unless $path_str; my @path = split /\\/, $path_str; # push the directories into an array push @directories, join "\\", @path[ 0, 5, 6 ]; } close IN; exit; # now we have a directory list in @directories let's process it # for my $dir ( @directories ) { # process_directories($dir); #} sub process_directories { if (/\.rtf$/) { push @directories, $File::Find::name; copy($File::Find::name, "C:\\testfiles\\$_") or die "Failed to cop +y $_: $!\n"; } } find(\&process_directories, $File::Find::dir);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: finding files and copying them using File::Fiind & File::Copy
by steves (Curate) on Feb 25, 2003 at 07:06 UTC |