in reply to NET::FTP put()/append() error handling

For starters, declaring my $ret twice in the same scope isn't going to work as expected. Consider this:
sub myohmy { my $y = shift; my $x = "true" if ($y); my $x = "not true" if (!$y); return $x; } print "myohmy(0) = ", myohmy(0), "\n"; print "myohmy(1) = ", myohmy(1), "\n"; __END__ # outputs: myohmy(0) = not true myohmy(1) =
use warnings will catch this problem. To fix it you'll need to re-write it as:
my $ret; $ret = ... if ($put_try == 0); $ret = ... if ($put_try > 0);
but I'd probably just use an if...else... construct.

Another issue with your retry logic is that if you want to recover from a failed put by appending data, you need to:

  1. figure out how much data was transfered by the put operation.
  2. open the source file and seek to that location
  3. perform an append operation using the opened file handle (as opposed to the source file's name)
It might be easier just to re-put the file (depending on its size.)

Replies are listed 'Best First'.
Re^2: NET::FTP put()/append() error handling
by Viki@Stag (Sexton) on Jul 02, 2008 at 07:00 UTC
    Thanks for the logic... ++
Re^2: NET::FTP put()/append() error handling
by Viki@Stag (Sexton) on Jul 02, 2008 at 07:06 UTC
    since this file is a binary file, should i use binmode(FILEHANDLE)?
      It wouldn't hurt, especially if you are on a Windows system. Net::FTP uses read() to read from the local file during a put.
        I am on Windows but the files can be on linux file system mapped on my Windows...