#!/usr/bin/perl $oldserv = "./testing"; $newserv = "./testing2"; $usernumfile = "./usrbynum.txt"; $usershortfile = "./srnames.txt"; open USERNUMS, "< $usernumfile" or die "$!"; open SHORTNAMES, "< $usershortfile" or die "$!";# open file with user while () { # loop through all lines of shortnames my ($longname,$shortname) = (split /:/)[7,0]; # seperate by those ugly colen $finishedusers{$longname} = $shortname; chomp %finishedusers; } my %lookup; # Hash %lookup while() { # loop through file with user numbers ($uid) = /(u\d{3,5})/; # User ID find yes ($longname2) = /([A-Z]\w+)/; chomp $longname2; $lookup{$longname2} = $uid; # Setup hash %lookup with keys "Long Name"=> "usernum" } while (($longname2, $uid) = each(%lookup)) { next unless exists $finishedusers{$longname2}; system ("cp '$oldserv/$uid/Documents/*' '$newserv/$finishedusers{$longname2}/Documents/'"); print "Copying Files for $finishedusers{longname2}"; } close USERNUMS; close SHORTNAMES;