Re: Getting error in Net::SFTP with get function



Jay Savage wrote:
On 10/31/07, Tom Phoenix <tom@xxxxxxxxxxxxxx> wrote:
On 10/31/07, Jay Savage <daggerquill@xxxxxxxxx> wrote:

Take another look at the Net::SFTP docs, particularly the note about
what get() does when called in a void context.
I see a note about a non-void context, but I don't see one about a
void context. The OP didn't use the get() method in a void context.
Did you mean to write "non-void"?

http://search.cpan.org/~dbrobins/Net-SFTP-0.10/lib/Net/SFTP.pm

As I interpret the docs, the OP's code should be correct. But maybe
I'm missing something.


I suppose I should have said non-void, because that is the behavior
the doc actually describes.

The assumption, though, is that void context will yeild the opposite
result. And it looks to me like OP is calling $sftp->get() in a void
context:

$sftp->get( $file, $localFile ) || warn("errrrr0rrrrr_--->
$!".$sftp->status."\n");

At least I'm not aware that that '||' forces any particular context on
the lefthand operand. Perlop mentions propagating context WRT the
righthand operand, but doesn't say anything about the left. So I would
expect get() to return the same in the following cases:

$sftp->get( $file, $localFile);
$sftp->get( $file, $localFile), print "something";
$sftp->get( $file, $localFile ) || die();

Given that, I would expect, from the docs, for get() to return the
empty string on success and undef on failure, both of which are
equally false from the perspective of '||'.

Or maybe *I'm* missing something?

perl -e "@x=(1,2,3); print @x || 99;"

Rob
.



Relevant Pages

  • Re: Perl style examples
    ... Semicolon seems to be missing at Perl_style_examples.pl line 192. ... Useless use of bitwise and in void context at Perl_style_examples.pl line 192. ...
    (comp.lang.perl.moderated)
  • Re: Getting error in Net::SFTP with get function
    ... what getdoes when called in a void context. ... I see a note about a non-void context, but I don't see one about a ... the lefthand operand. ... Or maybe *I'm* missing something? ...
    (perl.beginners)