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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.