Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How to parse a file with emails and IP's and output a sorted list with a total count

by Paladin (Vicar)
on Jul 28, 2016 at 23:13 UTC ( [id://1168772]=note: print w/replies, xml ) Need Help??


in reply to How to parse a file with emails and IP's and output a sorted list with a total count

I'm not sure why you are trying XML::Simple as there doesn't seem to be any XML involved. For data storage, you seem to need a hash of hashes. I'll assume you can get the IP and email address from the file.
my %users; foreach my $line (<$file>) { my ($email, $ip) = parse_line($line); $users{$email}{$ip}++; }
Then you'll have a hash that looks something like:
%users = ( 'joe@example.com' => { '192.168.10.24' => 2, '192.168.10.28' => 1 } );
  • Comment on Re: How to parse a file with emails and IP's and output a sorted list with a total count
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: How to parse a file with emails and IP's and output a sorted list with a total count
by mitzyc (Initiate) on Jul 28, 2016 at 23:21 UTC

    Yes! I can get the IP and the email.

    That little bit is enough to get me started. I really didn't know how to load and reference a hash with values.

    ...and no, I guess I didn't need XML at all.

    Thank you very much. This will give me a greater appreciation of how this works and a solid footing to start from.

    Thank you so much.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1168772]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-25 22:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found