I'm a perl beginner and trying to improve the re-usability of my code
I have a question regarding expect.pm, specifically how to create an abstract expect call.
Take this example:
@expectthese = ("pattern1", "pattern2", "pattern3"); @sendthese = ("string1", "string2", "string3"); $exp->expect($timeout, [qr/$expectthese[0]/, sub { select(undef, undef, undef, 0.25); $exp->send("$sendthese[0]"); do_stuff...} ], [qr/$expectthese[1]/, sub { $exp->send("$sendthese[1]"); select(undef, undef, undef, 0.25); do_other_stuff...} ], [qr/$expectthese[2]/, sub { $exp->send("$sendthese[2]"); select(undef, undef, undef, 0.25); do_this_stuff...} ], );
In this example expect simultaneously waits for 3 patterns to occur and then the respective stuff is done... How would I go about creating an abstract Block that would work in above way for @expectthese and @sendthese without pre-defining the amount of elements these arrays have and consequently without knowing how many [qr//,sub {do_stuff;}], blocks are needed?
Thanks in advance
In reply to abstract expect call by georgecarlin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |