use File::Spec; use File::Copy; my $file=File::Spec->catfile('\\serverA','dir','subdir','file'); my $newfile=File::Spec->catfile('\\serverB','dir','subdir','file'); my $errorfile=File::Spec->catfile('\\serverA','error_dir','file'); copy $file, $newfile or warn "Unable to copy $file to $newfile. $!"; if ($? > 0) { copy $file, $errorfile; } elsif ($? == 0) { unlink $file; }
Or something along those lines, but what if you are unable to make the second copy? or what if you are unable to unlink or otherwise remove the file? I'd also recommend using File::Spec to help with the paths and directory seperators, helps make it a bit cleaner, IMO :-)
update: Fixed the tags that were borked
In reply to Re: Check if "System" was succesful
by nimdokk
in thread Check if "System" was succesful
by LeeC79
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |