in reply to How to break while reading data from a Cisco router?

Check the documentation for the alarm function in perldoc.

Here is some example code for your situation;

my $timeout = 5; eval { local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required alarm $timeout; @data = $tnet->cmd('show ip cache flow'); alarm 0; }; if ($@) { die unless $@ eq "alarm\n"; # propagate unexpected errors # timed out } else { # didn't }