I updated this question since in the original question the problem I was pursuing turned out to be an all-encompassing other error (not interesting in this context). But the second-order error that I spent in testing is that others may come across and give an answer with a very interesting understanding, so I will leave this here as a question.
I was trying to identify a problem with regular expressions that don't seem to match due to leading zeros. I found that all of the following regexp do not match in my command line tests:
"005630" =~ /^0056(10|11|15|20|21|25|30|31)$/ "005630" =~ /0056(10|11|15|20|21|25|30|31)/ "005630" =~ /56(10|11|15|20|21|25|30|31)/ "005630" =~ /..56(10|11|15|20|21|25|30|31)/ "005630" =~ /..5630/ "005630" =~ /005630/ "005630" =~ /^005630$/ "005630" =~ /5630/ "005630" =~ /(0)*5630/ "005630" =~ /5630/g "005630" =~ m/5630/g
This corresponded to:
"x005630" =~ /0056(10|11|15|20|21|25|30|31)/
similar to others, i.e. as soon as I added the lead letter, it works.
Test code was tested with Cygwin Perl v5.10.1 on Cygwin bash):
perl -e "print ( "005630" =~ /0056(10|11|15|20|21|25|30|31)/)"
The quote here is obviously an error (you cannot use unescaped " in the line specified by " ). But I still do not understand why the second line works, despite the incorrect quoting.
Note. This can happen in other situations without regular expressions.
source share