File format:
user=john website="www.yahoo.com" type="Entertainment"
user=david website="www.facebook.com" type="Social Networking"
user=john website="www.facebook.com" type="Social Networking"
user=mike website="www.google.com" type="Search Engines"
####
john => [Website: www.yahoo.com , Category: Entertainment,
[Website: www.facebook.com, Category:Social Networking]
david =>[Website: www.facebook.com, Category:Social Networking]
mike=>[Website: www.google.com, Category:Search Engines]
####
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'
};