I would create a hash with hash references containing the date and an anonymous array as members. Something like this:
open FILE , 'C:\test.csv' or die $!; my %info while (<FILE>){ my ($logindate, $dbserver, $hostname, $status ) = split (/,/); $info{$username} = {$logindate=>[$dbserver, $hostname, $status]}; } On Mon, Sep 10, 2012 at 6:44 AM, andrew sison <andrew.sison...@gmail.com>wrote: > Hi, > > I'm confronted with this problem.I've done this before but I just > can't remember how. > > There is a log file I am trying to parse: > > open FILE , 'C:\test.csv' or die $!; > while (<FILE>){ > my ($logindate, $dbserver, $hostname, $status ) = split (/,/); > > } > > Now I want to use the $username as a name of a hash (sort of > dynamically create a variable. > > So if in the end I want to print all the login records of let's say > user "James", I would have a report like this: > > > James > Login Date DBServer Hostname Login Status > Aug 5 mailserver mail.co.xx Success > Sep 3 dnsserver dns.co.xx failed > > > Aron > Login Date DBServer Hostname Login Status > Jan 5 ftpserver ftp.co.xx Success > Oct 3 sshserver ssh.co.xx Success > > > I'm really lost here. I know I have to use some sort of nested hashes > but I just couldn't figure it out. > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- Danny Gratzer