in reply to Re: Perl's Expect - foreach loop
in thread Perl's Expect - foreach loop

The first command is only executed for each $table in @tables. Regarding the exp_continue command, this was tried but in would just keep cycling on the first $table. The command prompt is ">".

Replies are listed 'Best First'.
Re^3: Perl's Expect - foreach loop
by Roy Johnson (Monsignor) on Apr 28, 2005 at 18:27 UTC
    Still guessing, but I think what you want is multiple calls to expect, one for each time you want it to respond to something you've sent:
    $exp->expect(180, [ qr/>/i, sub { my $self = shift; sleep(1); $self->send("TABLE $table; FORMAT 132 PACK\r"); }]); $exp->expect(180, [ qr/UNKNOWN TABLE/i, sub { my $self = shift; sleep(1); $self->send("")ort\r"); next; }], [ qr/TABLE: $table/i, sub { my $self = shift; $self->send(""); }]); ...etc...

    Caution: Contents may have been coded under pressure.
      You were right, the multiple calls worked fine. I sincerely appreciate the assistance you have provide me, thank you very much!
      You were right, the multiple calls worked fine. I sincerely appreciate the assistance you have provided me, thank you very much!