use constant TARGET_STRINGS => qw(adice calibre vcs spectre incisive); my ($target) = map qr{ (?i) (?: $_) }xms, join q{|}, map quotemeta, reverse sort TARGET_STRINGS ; ... my $hit = my ($capture) = $columns[2] =~ m{ $target }xmsg; for my $ar_update ( # ref. to hash source column # to update of update [ \%pend_count, 4 ], [ \%run_count, 5 ], ) { my ($hr_update, $col) = @$ar_update; $hr_update->{$hit ? lc($capture) : 'others'} += $columns[$col]; }