Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Net::SFTP::Foreign error

by Perlbotics (Archbishop)
on Sep 25, 2018 at 18:45 UTC ( [id://1222994]=note: print w/replies, xml ) Need Help??


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";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1222994]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-20 00:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found