You probably have an older perl that does not understand the /r
Here's an alternate...
#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1168769 use strict; use warnings; my %ips; while(<DATA>) { /.* (\S+):(\S+)$/ or next; $ips{$1}{$2}++; } for my $who ( sort keys %ips ) { print $who; my @ips; for my $ip ( @ips = sort keys %{ $ips{$who} } ) { print "=> $ip ($ips{$who}{$ip})"; } print $who =~ /(.*?)\@/, " total: ", scalar @ips, " unique ip's\n"; } __DATA__ Jul 28 13:42:27 mail vpopmail[47985]: vchkpw-smtp: (PLAIN) login succe +ss joe@example.com:192.168.250.251 Jul 28 13:42:28 mail vpopmail[47992]: vchkpw-smtp: (PLAIN) login succe +ss joe@example.com:192.168.5.23 Jul 28 13:42:29 mail vpopmail[47994]: vchkpw-smtp: (PLAIN) login succe +ss sally@example.com:192.168.10.28 Jul 28 13:42:27 mail vpopmail[47985]: vchkpw-smtp: (PLAIN) login succe +ss fred@example.com:192.168.8.8 Jul 28 13:42:28 mail vpopmail[47992]: vchkpw-smtp: (PLAIN) login succe +ss joe@example.com:192.168.5.23 Jul 28 13:42:29 mail vpopmail[47994]: vchkpw-smtp: (PLAIN) login succe +ss harry@example.com:192.168.10.5
In reply to Re^3: How to parse a file with emails and IP's and output a sorted list with a total count
by Anonymous Monk
in thread How to parse a file with emails and IP's and output a sorted list with a total count
by mitzyc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |