# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv # The previous code block was replaced with code to # open remote and local files, then read the remote file # and write it to the local file. # The binmode() call is necessary because this is a # Windows(tm)-to-UNIX transfer and line-endings must # be preserved. my $rfh; # Remote File Handle $rfh = $sftp->open($sftpRemoteDir . "/" . $myFile); if (defined($rfh)) { if (open(LFH, ">$localDir\\$myFile")) { my $myLine; # Force binary transfers to preserve line endings # when transferring between Windows and UNIX. binmode(LFH); while ($myLine = <$rfh>) { printf(LFH "%s", $myLine); } close(LFH); } else { # ERROR: Could not open local file for transfer printf("Could not open local file '%s' for transfer\n", $myFile); } } else { # ERROR: Could not open remote file for transfer printf("Could not open remote file '%s' for transfer\n", $myFile); }