in reply to To find and count a repeating pattern in a line
poj#!perl use strict; my @from =(); my @to =(); my $re = qr/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/; while (<DATA>){ next unless /(?:to|from):$re/; push @from,($_ =~ /from:($re)/g); push @to, ($_ =~ /to:($re)/g); } for (@from){ print "$_ ,".(shift @to)."\n" } __DATA__ hshhhgljlkjglgkjj from:198.18.66.5 aegighighighilg to:198.18.66.6 iiuf +duifuiuih from:198.18.66.7 hiihhj to:198.18.66.8 hhouhoho from:198.18.66.9 igilgojhjh to:198.18.6 +6.10 igighliho from:198.18.66.11 highighioouhouhhhoh to:198.18.66.12
|
|---|