$exp->expect($timeout, [ qr/#/i, sub { my $self = shift; $self->send("ll\n"); <---- only works when I have a line below (crazy that is how I know this is not right) ; }], unless ($exp->expect($timeout, -re , "~")){} ; );