Irrelevant text. Irrelevent text. More text. ##This is the data that I am interested in.## More text. More text. #### my %mycorpus = getCorpus('C:\Users\li\test4'); my %counts; foreach my $filename (sort keys %mycorpus) { my $date; my $tags; my $comments; my $word; if ($mycorpus{$filename} =~ /(?<==)(\d{4}-\d{2}-\d{2})(?=T)/g){ $date = $1; } if ($mycorpus{$filename} =~ /\bsoft/gi){ $counts{$date}++; } } foreach my $date (sort keys %counts){ print "$date = $counts{$date}\n"; } #### 2017-08-31 = 42 2017-09-01 = 25 2017-09-02 = 40 2017-09-03 = 34 2017-09-04 = 26 ..... #### my %mycorpus = getCorpus('C:\Users\li\test4'); my %counts; foreach my $filename (sort keys %mycorpus) { my $date; my $tags; my $comments; my $word; if ($mycorpus{$filename} =~ /(?<==)(\d{4}-\d{2}-\d{2})(?=T)/g){ $date = $1; } if ($mycorpus{$filename} =~ /(?<=##)(.*)(?=##)/g){ $hashtags = $1; } if ($hashtags =~ /\bsoft/gi){ $counts{$date}++; } } foreach my $date (sort keys %counts){ print "$date = $counts{$date}\n"; } #### 2017-09-01 = 1 2017-09-02 = 3 2017-09-03 = 6 2017-09-04 = 2 2017-09-05 = 1 2017-09-06 = 3 2017-09-07 = 3