I think you are overcomplicating a simple task: infact i suppose (at first glance) that your double use of the diamond
<> operator is the cause of your output (PS infact every call of
<> consume one line of the filehandle).
Why do not simply (untested):
while (<>){
if (/^Relay access denied/){
foreach (<>){
print "$2\n" if $_ =~ /(\d+)\s+(\S+)/;
}
}
}
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.