in reply to Net::SFTP::Foreign error

... as haukex said or hack your way around it:

... warn( "Put failed: @{[$sftp->error]} \n" ) ...

Update to response below:

The @{ ... } dereferences an array-ref. By default, the resulting string is a space separated (see $" in perlvar) concatenation of the array elements. However, $sftp->error() returns a scalar (string). Here, the square brackets come into play. They generate an anonymous array - with one single element - that finally is dereferenced and interpolated.

It's somewhat equivalent to: warn( "Put failed: " . join($", @{ [ $sftp->error() ] }) . " \n" );

Replies are listed 'Best First'.
Re^2: Net::SFTP::Foreign error
by roperl (Beadle) on Sep 25, 2018 at 20:30 UTC
    Ok thanks
    @{[$sftp->error]}
    worked I was trying with @{$sftp->error} Can you explain what the brackets are doing exactly?
      @{[$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";