##
# copy.pl
my $test = system('perl', 'write.pl');
my $file1 = 'foo.txt';
my $status = system("cp $file1 file2");
####
$ perl -w copy.pl
cp: cannot stat `foo.txt': No such file or directory
####
# copy2.pl
use strict;
my $test = system('perl', 'write.pl');
my $file1 = 'foo.txt';
while(1) {
last if -e $file1 && ! qx/lsof $file1/;
}
my $status = system("cp $file1 file2");