#!/usr/bin/perl use strict; use warnings; sub catch_zap { my $signame = shift; die "Somebody sent me a SIG$signame"; } $SIG{INT} = \&catch_zap; # best strategy $SIG{TSTP} = \&catch_zap; # best strategy my $t = time; $t += 30; while ( time < $t ) { print scalar localtime, qq{\n}; sleep 1; } #### #!/usr/bin/perl use strict; use warnings; my $interface; open( CMD, "/sbin/ifconfig |" ) || die "can't fork: $!"; while () { if (/^(\S+)/) { $interface = $1; } next if !/(inet\d?)\s+addr:\s?(\S+)/; print $interface, q{ }, $1, q{: }, $2, qq{\n}; } close CMD || die "bad cmd: $! $?";