while () { chomp; if (/^(19|20)([5-9]|[0-5])([0-9])$/) { print "it matches for $_\n"; } } __DATA__ 1950 2050 2001 2009 2000