my @matchers = ( qr/(Lz0|PLATO)/i, 'Apps', qr/(SKIDROW|POSTMORTEM|RELOADED|THETA|TiNYiSO|HI2U|TE|FLT|PROPHET|Unleashed|OUTLAWS|ALiAS|JAGUAR)/i, 'Games', ... ); for (my $idx = 0; $i < @matchers; $i += 2) { if ($release_name =~ $matchers[$i]) } $category = $matchers[$i + 1]; print "[INFO] Category: $category"; last; # stop after the first category was found } } # code not tested