Relay access denied (total: 13) 1 46.183.217.174 1 46.183.220.137 1 46.183.220.138 1 46.183.220.139 1 46.183.223.239 1 218.38.243.204 1 185.29.8.198 1 185.29.9.133 1 185.29.9.135 1 46.183.217.162 1 46.183.217.165 1 46.183.217.169 1 91.236.75.169 Sender address rejected: Access denied (total: 50) #### use strict; use warnings; my $ip=""; while (<>) { if (/Relay.access.denied/) { do { print "$2\n" if <> =~ /(\d+)\s+(\S+)/; $ip = $2; } until (<> !~ /(\d+)\s+(\S+)/); } } #### 46.183.217.174 46.183.220.138 46.183.223.239 185.29.8.198 185.29.9.135 46.183.217.165 91.236.75.169