use Regexp::Common; if ($tag =~ /^$RE{num}{int}{-sep => ','}$/) { ... }