I really need help. I've been trying to code this myself for over 3 hours now, and nothing I do works.

I have a vpopmail file like this:

Jul 28 13:42:27 mail vpopmail[47985]: vchkpw-smtp: (PLAIN) login success joe@example.com:192.168.250.251
Jul 28 13:42:28 mail vpopmail[47992]: vchkpw-smtp: (PLAIN) login success joe@example.com:192.168.5.23
Jul 28 13:42:29 mail vpopmail[47994]: vchkpw-smtp: (PLAIN) login success sally@example.com:192.168.10.28
Jul 28 13:42:27 mail vpopmail[47985]: vchkpw-smtp: (PLAIN) login success fred@example.com:192.168.8.8
Jul 28 13:42:28 mail vpopmail[47992]: vchkpw-smtp: (PLAIN) login success joe@example.com:192.168.5.23
Jul 28 13:42:29 mail vpopmail[47994]: vchkpw-smtp: (PLAIN) login success harry@example.com:192.168.10.5

I'm trying to write a routine that reads in this file, sorts the list, and gives a count:

joe@example.com
=> 192.168.250.251 (1)
=> 192.168.5.23 (2)
joe total: 2 unique IP's

sally@example.com
=> 192.168.10.28 (1)
sally total: 1 unique IP's

I know basic perl. But object oriented programming is something I'm trying to learn, but I just can't seem to get it.

If I had a working example written like this.. I could understand it better, and then be able to finally get how it works when I see the code.

The output format doesn't have to be exact.

I'm hunting to see how many unique IP addresses a person is successfully logging in from and output the counts

I tried playing with XML::Simple, and gave up when I got this:

Can't call method "address" on unblessed reference

#!/usr/bin/perl use XML::Simple; my $xml = new XML::Simple; my $sender = { 'address' => 'joe@example.com', 'ips' => ["12.52","13.53","14.54.55"], }; # add another IP to an existing user $sender->address->'joe@example.com' {; ->ips = "16.70.71"; };

I know I'm screwing up syntax, and all the examples I've been trying to incorporate never seem to work. I'd have a longer code sample if I had it, but I kept erasing my code and trying again, and again, and again.

This led me to Perl Monks. Please help if you can. :)

- Mitzy


In reply to 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.