print "$command\n"; $exp->send("$command\n"); $exp->expect(1, '-re','\(\d+\)'); #### $exp->send("$command\n"); print "$command\n"; $exp->expect(1, '-re','\(\d+\)'); #### my $counter = 1; print "($counter) "; #### my $counter = 0; #### (1) (2) Here is the second command #### while () { chomp; $counter++; print "($counter) $_\n"; if ($_ eq "error") {print "Error on command #$counter\n";} if ($_ eq "commit") {print "Committing data\n";} if ($_ eq "exit") {print "Exiting program...\n"; exit;} }