in reply to copy files on sftp to local dir and delete copied file

but they always complain that my localdir is a directory
Just guessing: so try to give them a file path?
$sftp->get($file->{filename}, LOCAL_DIR . '/' . $file->{filename});
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: copy files on sftp to local dir and delete copied file
by salva (Canon) on Sep 24, 2015 at 12:02 UTC
    Yes, that's right. Net::SFTP::Foreign requires the target argument to be the full file name.

    It favors predictability over DWIM.

Re^2: copy files on sftp to local dir and delete copied file
by mariog (Acolyte) on Sep 24, 2015 at 13:13 UTC

    Hello

    that seems to work

    I needed to change the ls because it was still crashing due to . and .. directories.

    so I set like this:

    my @files = @{ $sftp->ls(no_wanted => qr/^\./)

    this seems to work okay..

    thanks alot.

      Are you sure you want to eliminate anything that begins with '.' (just asking, you very well might)? If not, it would likely be better to explicitly call out '.' and '..'.

      You may also want to consider what you mean by success. For example, are you certain the remote side is not being written to? There is a race condition between the get and the remove calls. OTOH, if the source location is unchanging (other than this script), you may be just fine.

      --MidLifeXis