|
From: Roland G. <RGi...@CP...> - 2001-12-17 21:32:46
|
> I'm not exactly sure what parameters a timeout handler gets. I originally
> expected it to get the Expect object as its first parameter, like the other
> handlers in an expect().
That's a little bit of a problem if you have multiple expect objects (using '-i').
Which one should it get? Should multiple timeout handles be allowed, one for
each '-i'? I was in a hurry and decided to make timeout handlers global
to all expect objects in that expect() call.
> A useful workaround is to use a closure for the handler:
>
> my $exp = Expect->spawn(...);
> $exp->expect(10,
> [qr/this.*/ => sub { $exp->send($response) } ],
> [timeout => sub { $exp->send($workaround) } ]);
>
> In this way, it's not necessary to access the parameter list in the
> handlers.
Right. And it also works for multiple expect objects. I will put that into
the docs...
> Internally, I'm thinking _multi_expect() could use some reorganization to
> call all the handlers in the same way. Then, timeout handlers could use
> exp_continue, receive the Expect object as a parameter, etc.
You're right, the whole code could use a lot of cleanup. But as Expect2
is becoming a possibility, anything invested here is wasted.
> Hope I don't sound like I'm complaining; Expect.pm still rocks my world!
Not at all! Constructive criticism is always welcome.
Roland
--
RGi...@cp...
|