open FILE, "new.log" or die; my %hoh; while () { if ($_ =~ /user="([^"]+)/) {$user = $1; } if ($_ =~ /website="([^"]+)/) {$website = $1; } if ($_ =~ /type="([^"]+)/) {$type = $1; } # shows only one website per user $hoh{$user}->{'Website'} = $site; $hoh{$user}->{'Category'} = $cat; } use Data::Dumper; print Dumper (%hoh); Output: $VAR1 = 'john'; $VAR2 = { 'Type' => 'Social Networking', 'Website' => 'www.facebook.com' }; $VAR3 = 'mike'; $VAR4 = { 'Type' => 'Search Engines', 'Website' => 'www.google.com' }; $VAR5 = 'david'; $VAR6 = { 'Type' => 'Social Networking', 'Website' => 'www.facebook.com' };