I have a loop that goes trough a list of records but it jumps every two records
This the file:
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)
And this is my code
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+)/);
}
}
The output I get is :
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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.