use warnings;
use strict;
use constant {
IDLE => 0,
IP_ADDRS => 1,
};
my $state = IDLE;
while (<>) {
if ($state == IDLE) {
if (/Relay.access.denied/)
{ $state = IP_ADDRS }
}
elsif ($state == IP_ADDRS) {
if (/(\d+)\s+(\S+)/)
{ print "$2\n" }
else
{ $state = IDLE }
}
}
####
use warnings;
use strict;
while (<>) {
if (/Relay.access.denied/) {
while (<>) {
/(\d+)\s+(\S+)/ or last;
print "$2\n";
}
}
}
####
use warnings;
use strict;
use constant {
IDLE => 0,
IP_ADDRS => 1,
};
my $state = IDLE;
while (<>) {
chomp;
if (/Relay.access.denied/) {
if ($state == IDLE)
{ $state = IP_ADDRS }
elsif ($state == IP_ADDRS)
{ warn "unexpected: $_" }
}
elsif (/(\d+)\s+(\S+)/) {
if ($state == IDLE)
{ warn "unexpected: $_" }
elsif ($state == IP_ADDRS)
{ print "$2\n" }
}
else {
if ($state == IDLE)
{ }
elsif ($state == IP_ADDRS)
{ $state = IDLE }
}
}