$telnet->waitfor(Match => m{$last_line_of_the_1st_menu}smx); $telnet->print(q{a}); $telnet->waitfor(Match => m{$last_line_of_the_2nd_menu}smx); $telnet->print(q{b});