in reply to efficiency & style

You can substitute this:
foreach (@tcpstatus) { while (/\b01\s/) { push(@tcpalive,$_); last; } }
for this:
@tcpalive = grep { /\b01\s/ } @tcpstatus;