On Mon, Sep 10, 2012 at 7:12 AM, Danny Gratzer <danny.grat...@gmail.com> wrote:
> while (<FILE>){
> my ($logindate, $dbserver, $hostname, $status ) = split (/,/);
>     $info{$username} = {$logindate=>[$dbserver, $hostname, $status]};
> }

One thing to watch for - logins on the same day will overwrite here, so
while (<FILE>){
     my ($logindate, $dbserver, $hostname, $status ) = split (/,/);
     push ( @{ $info{$username}->{$logindate} }, [$dbserver,
$hostname, $status]  );
}

So, when you fetch the via the key and then via the date, you're
getting back an anon array of array, which'll require one more foreach
loop, "casting" that to an array (via "@{ ... }") - this seems to
work:
my %info;
while (<DATA>){
     my ($username, $logindate, $dbserver, $hostname, $status ) = split (/,/);
     push ( @{ $info{$username}->{$logindate} }, [$dbserver,
$hostname, $status]   );
}

use Data::Dumper;
print Dumper(\%info);

__DATA__
James,12/1/2012,foo,bar,success
James,12/1/2012,hoo,tar,fail
Bill,12/1/2012,foo,bar,success
Mark,12/1/2012,hoo,tar,fail


-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to