$IsNumber = '^\d+$'; ($rValue=~$IsNumber); # Returns 1 if the regex matches # Or this returns the numeric $rValue if it matches $IsNumber # else returns "" ($rValue=~$IsNumber && $rValue);