in reply to Re: Re: Re: copy files
in thread Global symbol $dir requires a explicit package name ?

Cabrion, I change my code a bit but I still cannot get it to work. I keeps givng me "Global Symbol $dir requires explicit package name in line 32 and 35" I'm really hitting a wall could you help??? I don't know why it keeps giving me the error. I really need to do a recursive directory search. I'll appreciate your help...
#! 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); } find(\&process_directories, $dir); sub process_directories { if ($File::Find::dir ne $dir) { $File::Find::prune = 1; return 0; } return 0 if ($_ !~ /\.rtf$/); copy($File::Find::name, "C:\\testfiles\\$_") or die "Failed to cop +y $_: $!\n"; return 1; }