use strict; while () { chomp; print "$_ is ", /^(?:19|20) (?: (?:(?<=19)[5-9]|(?<=20)[0-4])[0-9] | 50)$ /x ? "Ok" : "not ok", "\n" } __DATA__ 1050 1950 2050 2054 1980 2004 3100