From: John B. (Lists) <li...@jo...> - 2007-03-19 23:42:25
|
Hi all, Trying to drive an interactive session with some telecomms kit. It's a very simple interface - it gives a series of fixed prompts to which the user enters a response, nothing fancy but quite tedious. I have a Perl hash with the prompts as keys and the responses as the hashed values. Example of a session... REQ NEW TYPE TIE CUST 0 ... where REQ, TYPE and CUST are the kit's prompts - always on a new line ending with a space. NEW, TIE and 0 are the corresponding responses. So the draft code is... $exp->expect($timeout, [ qr/^REQ /, sub { $self = shift; $self ->send($args{"REQ"}, "\n"); exp_continue } ], [ qr/^TYPE /, sub { $self = shift; $self ->send($args{"TYPE"}, "\n"); exp_continue; } ], [ qr/^CUST /, sub { $self = shift; $self ->send($args{"CUST"}, "\n"); exp_continue; } ], # Hundreds more patterns here... ... ... ); This works fine however I'd like to build the expect loop during execution using the %args hash as it's easier to add hash pairs than have to modify code when a new prompt appears. Is this supported with Expect.pm? If so, any hints on the best way to code this? Thanks, John. |