in reply to Re: Net::SFTP::Foreign error
in thread Net::SFTP::Foreign error

Ok thanks
@{[$sftp->error]}
worked I was trying with @{$sftp->error} Can you explain what the brackets are doing exactly?

Replies are listed 'Best First'.
Re^3: Net::SFTP::Foreign error
by AnomalousMonk (Archbishop) on Sep 25, 2018 at 21:37 UTC
    @{[$sftp->error]}

    ... what the brackets are doing ...

    See the "Baby cart" idiom in perlsecret.

    Update:

    @{[$sftp->error]}
    Note also that as  $sftp->error (I assume; haven't checked) returns a scalar, not a list,
        ${ \$sftp->error }
    would have worked as well in a string interpolation.


    Give a man a fish:  <%-{-{-{-<

      Frankly, why would you like to use the baby cart when you can use the shorter and easier to understand crab operator? ".."

      As in...

      $a = "some ".$foo->bar." text";

        Indeed. Or, in the (list) context of the original question, why would one want to bother even to understand  . (concatenation) or a crab when  , (comma) will do:
            warn "Put failed: ", $sftp->error, "\n";
        (and it looks better, too, IMHO :).


        Give a man a fish:  <%-{-{-{-<