my $price = "100.09"; if ($price =~ / ^ # We begin at the start of the string [0-9]+ # At least one digit, possibly followed by more ( # Then (possibly, see below) follows \. # a dot [0-9][0-9] # and two more digits )? # But the decimal part is optional $ # And that's all there is to be /x) { } elsif { die "'$price' dosen't look like a valid price.\n" };