To check the date passed with a script, I first check that the date
is in the format 20dddddd (20 followed by 6 digits exactly)

But the regex is wrong, tried /^20\d{6}/,/^20\d{6,6}?/,/^20\d{6,}?/ and
while a 7 or lesser digit number fails, eg 2009101, a 9 digit number,
like 200910103 does not fail.



unless ( $ARGV[2] =~ /^20\d{6}?/ ) { print
"$ARGV[2]\tdate format is YYYYMMDD, eg 20091031\n"; }


How do I get the regex to fail a 9 digit number


I suppose as a work around, I could say;

unless ((length($ARGV[2]) == 8) and ( $ARGV[2] =~ /^20/){fail}

TIA


Owen

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to