Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have a loop that goes trough a list of records but it jumps every two records
This the file:And this is my codeRelay 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)
The output I get is :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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Loop problem: jumps one record
by hippo (Archbishop) on Jan 31, 2017 at 10:48 UTC | |
by math&ing001 (Novice) on Jan 31, 2017 at 12:05 UTC | |
by hippo (Archbishop) on Jan 31, 2017 at 13:43 UTC | |
|
Re: Loop problem: jumps one record (updated)
by haukex (Archbishop) on Jan 31, 2017 at 11:03 UTC | |
by math&ing001 (Novice) on Jan 31, 2017 at 11:59 UTC | |
by Discipulus (Canon) on Jan 31, 2017 at 12:39 UTC | |
by haukex (Archbishop) on Jan 31, 2017 at 12:26 UTC | |
by math&ing001 (Novice) on Jan 31, 2017 at 12:54 UTC | |
by haukex (Archbishop) on Jan 31, 2017 at 13:13 UTC | |
by tybalt89 (Monsignor) on Jan 31, 2017 at 18:24 UTC | |
by poj (Abbot) on Jan 31, 2017 at 13:03 UTC | |
| |
|
Re: Loop problem: jumps one record
by Discipulus (Canon) on Jan 31, 2017 at 10:48 UTC | |
|
Re: Loop problem: jumps one record
by johngg (Canon) on Jan 31, 2017 at 12:51 UTC | |
|
Re: Loop problem: jumps one record
by math&ing001 (Novice) on Jan 31, 2017 at 13:29 UTC | |
|
Re: Loop problem: jumps one record
by Anonymous Monk on Jan 31, 2017 at 10:54 UTC | |
by Anonymous Monk on Jan 31, 2017 at 18:41 UTC |