bash$ perl -e 'use Time::Piece; localtime()->strptime(@ARGV[0], "%Y-%m"); print "ok\n"; ' "2019-01" ok bash$ perl -e 'use Time::Piece; localtime()->strptime(@ARGV[0], "%Y-%m"); print "ok\n"; ' "2019-77" Error parsing time at /usr/lib/x86_64-linux-gnu/perl/5.26/Time/Piece.pm line 481.