This isn't really a Win32::OLE issue.  There are two different
philosophies when it comes to returning success or error from a
function:

1.  The kind of function you run into most frequently in Perl is the
kind that will return a "false" value on error (usually 0), and a "true"
value on success (usually either 1 or whatever data you were
requesting).

2.  The second kind of function is less often seen in Perl, but it acts
the way most programs do.  These functions return 0 on success, and
return an error code on failure.  The problem is that if you run into
these, you can't use the "function() or die;" semantics people are used
to because the "or" part of the statement will be executed on success
instead of failure.  If you change your line to be 

   !$SFTPServer->connect( $Server, $Port, $UserName, $Password ) 
   or die "Could not connect as $UserName to $Server:$Port!";

you might get the results you wanted.



________________________________________
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 25, 2006 6:23 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; Timothy Johnson;
[EMAIL PROTECTED]
Cc: perl-win32-users@listserv.ActiveState.com
Subject: Resolved - Question about Win32::OLE

First, thanks to all who offered their assistance. I spent many hours
trying to make my simple test script work...and it does (did)! Darn
thing had been working all the time (very embarassing).
The problem seems to be die or warn in this line: 
$SFTPServer->connect( $Server, $Port, $UserName, $Password ) or die
"Could not connect as $UserName to $Server:$Port!"; 
This line does not cause the error message. 
$SFTPServer->connect( $Server, $Port, $UserName, $Password ); 
Apparently, both versions were actually making a connection while I
thought it was failing because of the message. I'm guessing that
die/warn should not be used with win32::OLE. LastError seems the correct
construct.
Again, thanks to all 
Sturdy 


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to