if ($totalOutput =~ /^Project : error (\w+)/) { my $project = $1; ... }