-
-
Save dearenot/76494e3c1372562d0f0c69ca35975293 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use strict; | |
| my %questGroups; #hash <date, %hash<type, @events>> | |
| my $itemId = "1101"; | |
| my $itemChange = "+"; | |
| my $itemChangeRegex = qr /(?<=change=)(.*?)(?=[0-9])/; | |
| my $itemIdRegex = qr /(?<=itemID=)(.*?)(?=,)/; | |
| my $dateRegex = qr/(\d\d\.\d\d\.\d\d\d\d)/; | |
| my $questTypeRegex = qr/(?<=type:)(.*?)(?=,)/; #between 'type:' and comma | |
| open(DATA, "<", "testLog.log") or die "Couldn't open file file.txt, $!"; | |
| while(my $line = <DATA>) { | |
| my $currentItemId = $1 if $line =~ $itemIdRegex; | |
| my $currentItemChange = $1 if $line =~ $itemChangeRegex; | |
| if ($currentItemId eq $itemId && $currentItemChange eq $itemChange) { | |
| my $date = $1 if $line =~ $dateRegex; | |
| my $questType = $1 if $line =~ $questTypeRegex; | |
| print "$questType\n"; | |
| if (exists $questGroups{$date}){ | |
| # push (@{ $questGroups{$date} }, $line); OLD | |
| #new functionality | |
| my %currentDateHash = $questGroups{$date}; | |
| if (exists $currentDateHash{$questType}) { | |
| print "yes\n"; | |
| push (@{$currentDateHash{$questType}}, $line); | |
| } else { | |
| print "no\n"; | |
| my @tempArr = ($line); | |
| $currentDateHash{$questType} = \@tempArr; | |
| $questGroups{$date} = \%currentDateHash; | |
| } | |
| } | |
| else { | |
| print "else\n"; | |
| # my $questType = IMPL | |
| # my %tempHash = ($questType => $line - @arr!) IMPL | |
| my @tempArr = ($line); | |
| my %tempHash = ($questType => \@tempArr); | |
| # $questGroups{$date} = \@tempArr; OLD | |
| $questGroups{$date} = \%tempHash; | |
| } | |
| } | |
| } | |
| print "dates are\n\n\n"; | |
| # while( my( $key, $value ) = each %questGroups ){ | |
| # print "[$key]: \n\n"; | |
| # print "@{$questGroups{$key}} \n\n"; | |
| # } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment