foreach (@tcpstatus) { while (/\b01\s/) { push(@tcpalive,$_); last; } }