Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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, http://cpansearch.perl.org/src/RGIERSIG/Expect-1.21/Expect.pm, 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 Expect.pm (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)).

In reply to Re: Perl Expect Send Slow Oddness by quester
in thread Perl Expect Send Slow Oddness by setuk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-23 20:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found