in reply to help with a regex

$mday =~ /\A(1|18)\z/

Read perlre to find out what it means.

Also you could use hashes for the months.