in reply to grep all matches
Replace
my ($failedTest) = grep { /FAIL/ } @reportContents; ... [download]
with
for my $failedTest (grep { /FAIL/ } @reportContents) { ... } [download]
🦛