Chris Wagner wrote:
> At 02:04 PM 12/4/2008 -0600, SelfSimilar wrote:
>   
>>> try something like
>>>
>>> print $buf while (($len = $chan->read($buf,512))||0) > 0);
>>>       
>> Thank you for the suggestion. Unfortunately, it get the same error warning
>>
>> Use of uninitialized value in numeric gt (>) at SFTP_test2.pl line 21
>>     
>
> I have to chime in.  That kind of construct is just plain wrong. :)  U need
> an if{} block to test for every possible return type of $chan->read().  i.e.
> blank, undef, valid number, invalid number, and other junk.  U've fallen
> into the one liner trap.  Laziness *is* the cardinal virtue of the
> programmer, but u can still be burned by it.
>
>
>
>
> --
> REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 >=--
> "...ne cede malis"
>
> 00000100
>
>   
Uh, I think you are just complaining about one of your pet peeves :) -- 
His example is simplified, if not *lazy*  as you put it, in its entirety 
much like the suggestion that I provided to him.  It also didn't work 
for him.  The docs or Channel.pm code do not seem to indicate the return 
types you have mention here beyond -- bytes read or undef -- so I'm not 
sure how you would code against all of those conditions unless you are 
suggesting one should code based on speculation alone.  I believe I 
would continue on the "lazy" route if that is the case. 

If he's really concerned about ensuring that he gets all of the output 
-- he needs to consider using $channel->exec otherwise even with adding 
delays (ie. using select calls) *inside* the while loop it still may not 
be long enough of a wait for read to be able to pull in all the output 
as it will probably return undef several times.  Unless, that is, he's 
ok with adding in several seconds of delays as needed to cover all types 
of commands or scripts he'd run.



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

Reply via email to