in reply to Re: How to end "do" with Ctrl-C
in thread How to end "do" with Ctrl-C
use strict; my $port = shift; our $stopit = 0; $SIG{INT} = sub { $stopit++; }; if (!$port or $port =~ /\D/) { print "usage: program port_num\n"; } else { while (!$stopit) { print system("netstat -an | grep $port"), "\n"; sleep 10; } }
or whatever variant will get you what you want.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to end "do" with Ctrl-C
by ikegami (Patriarch) on Dec 03, 2008 at 00:12 UTC | |
|
Re^3: How to end "do" with Ctrl-C
by st_possenti (Monk) on Dec 02, 2008 at 23:13 UTC |