C:\>perl -lne "print m/^\d{5}$/ ? ' OK' : ' Fail'" 5 Fail 12345 OK 123 Fail Hello Fail 3.141 Fail ^Z