use strict; use warnings; use Test::More tests => 2; my %mycorpus = ( a => "

Irrelevant text that may feature the word soft, softest, or softly. ar##*whispers softly* don\'t## ##very soft## ##the softest even## — 164 notes", b => "p> Irrelevant text that may feature the word soft, softest, or softly. 4r##skam## rr##isak valtersen## rr##even bech næsheim## dr##god## r##they're so soft## sr##my heart is bursting## ##This is the softest## — 379 notes Irrelevant text that may feature the word soft, softest, or softly.", c => "

##SKSNSKXBXKXND## r##I LOVE THESE## ##such soft boyfriend™## ##you're my sunshine## — 180 notes Irrelevant text that may feature the word soft, softest, or softly." ); my %counts; foreach my $filename (sort keys %mycorpus) { my $date; my $hashtags = ''; if ($mycorpus{$filename} =~ /(?<==)(\d{4}-\d{2}-\d{2})(?=T)/g){ $date = $1; } if ($mycorpus{$filename} =~ /[#][#](.*)[#][#]/g){ $hashtags = $1; } if (my $matches =()= $hashtags =~ /\bsoft/gi){ $counts{$date} += $matches; } } is ($counts{'2017-09-04'}, 4, "2017-09-04 tally correct"); is ($counts{'2017-09-30'}, 2, "2017-09-30 tally correct");