Question : program returns false missing files after find the files

I have a short script that reads from a list, copies the files from the list, makes a txt file of the copied files, makes a text file of the files it is looking for and makes a txt file of the files it couldn't find. The problem is that it lists some files as missing even though it found them and copied them. I can't see the error so if someone would point this out, it would be great.
I have included the code and files.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
#!/usr/bin/perl

use strict;
use warnings;
use File::Find;
use File::Copy;
use Data::Dumper;


my $SrcRootDir = 'G:/data/';
my $SrcRootDir_old = 'G:/data/old/';
my $DestRootDir = 'Z:/transfer';
my $transfer = 'Z:/transfer/transfer_list.txt';
my %file;
my %file2;
my %file3;
my ($file1, $file2);


my $Track='Z:\transfer\tracking.txt';
my $old_files='Z:\transfer\Old_Files.txt';
my $Missing_files='Z:\transfer\Missing_Files.txt';
my $Copied_files='Z:\transfer\Copied_Files.txt';

open(TRACK,">$Track");
open(MISSING_FILES,">$Missing_files");
open(COPIED_FILES,">$Copied_files");
print COPIED_FILES "getting files from list\n";
print COPIED_FILES "\n";


open(IN, '<', $transfer) or die "Could not open $transfer: $!\n";
while(<IN>) {
      chomp;
      # my ($filename) = ($_ =~ /^(.+)\..+$/);
       my ($filename) = ($_ =~ /^(.+)(\_.+)?$/);
      $file{lc($filename)}++;
print "getting files $filename\n";
}
close(IN);


find(\&wanted, $SrcRootDir);


close(TRACK);
close(COPIED_FILES);

print MISSING_FILES "These are the drawings that could not be found\n";
print MISSING_FILES "Please check for incorrect drawing numbers in list\n";
print MISSING_FILES "\n";


my %file1;
open (FILE1, 'T:\Team\transfer\tracking.txt') or die "Could not open $Track: $!\n";
while(<FILE1>) {
 $file1{lc $_}=1;
}
close(FILE1);

open (FILE2, 'T:/team/transfer/transfer_list.txt') or die "Could not open $transfer: $!\n";
while (<FILE2>) {
  unless ($file1{lc $_}) {
    print $_;
print MISSING_FILES "$_\n";
  }
}
close(FILE2);

close(MISSING_FILES);

sleep(10); 

exit;

sub wanted {

if ( $File::Find::dir = /old/ ) 
	{$File::Find::prune = 1;
	return;
	}

#    my ($filename) = ($_ =~ /^(.+)(\.+)?$/);
 my ($filename) = ($_ =~ /^(.+)\_.+$/);
# print "getting file $filename\n";
    return unless exists $file{lc($filename)};
   print "Copying $File::Find::name to $DestRootDir\n";
# print TRACK "$File::Find::name\n"; 
print TRACK "$filename\n";
print COPIED_FILES "$filename\n";



    # copy($File::Find::name, "$DestRootDir/$_") or warn "Could not copy $_: $!\n";
copy($File::Find::name, "$DestRootDir/$_") or print TRACK "Could not copy $_: $!\n";

}
Attachments:
 
copied files
 
 
missing files
 
 
tracking file
 
 
original list
 

Answer : program returns false missing files after find the files


DoCmd.OpenForm "frm_CampaignDetail",acNormal,,"CampaignID = " & Me.CampaignID,,acDialog
Random Solutions  
 
programming4us programming4us