Why reinvent the wheel? (Unless you're doing this as a learning exercise, of course.)The people who wrote rsync have done the heavy lifing here, and the Perl interface is at File::Rsync.
Comment on Re: recursively compare folders in windows, synchronize the two folders with the newest files