mitzyc has asked for the wisdom of the Perl Monks concerning the following question:
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