On Mon, Sep 10, 2012 at 5:14 PM, 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 $!; > Use below method to open the file , $file now contain file handle. open my $file, '<' ,'C:\test.csv' for die "Not able to open test.csv $!"; while (<$file>) { do something; } > 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/ > > > -- Praveen Kumar http://fedoraproject.org/wiki/User:Kumarpraveen http://fedoraproject.org/ http://kumar-pravin.blogspot.com