local $\ = "\n"; # line feed at end of print while(<>) { if(/\bPeer: (\w):\s+(\d+\.\d+\.\d+\.\d+):\s*(\d+)/) { print $2; } }