Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Perl Expect Send Slow Oddness

by quester (Vicar)
on Jul 31, 2009 at 13:43 UTC ( #784897=note: print w/ replies, xml ) Need Help??

in reply to Perl Expect Send Slow Oddness

This is partly guesswork since I'm not at my Perl machine to test my theory at the moment, but...

in the source for Expect,, the definition of send_slow contains this...

sub send_slow{ ... while ($chunk = shift) { @linechars = split ('', $chunk); foreach $char (@linechars) { ...
The while condition really should have been (defined ($chunk = shift)) in order to avoid falling out of the loop when $chunk is false. (In your case it's "0" which is false, but "" would cause the same problem.)

You could patch your copy of (and optionally submit the patch to the module author for good karma.)

Oc you could just patch your own code to work around it, which is the path of least resistance. According to the documentation, send_slow pauses after every individual character, not just after each string argument. So you could try changing these lines in your code
my @SlowChars = split(//,$_send); print Dumper(@SlowChars); my $return = $exp->send_slow(1,@SlowChars);
to just
print Dumper($_send); my $return = $exp->send_slow(1,$_send);

Update: Remembered to add the inner parentheses to (defined ($chunk = shift)).

Comment on Re: Perl Expect Send Slow Oddness
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-12-01 04:50 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (794 votes), past polls