in reply to POSIX-Style character classes

I would argue that (quoting for windows users; language pedantry re digits for any who stumble upon this):
C:\>perl -e "if('42'=~ /^[[:digit:]]$/) {print qq(42 is a digit\n)} else {print qq(42 is not a digit\n)};"
which prints
42 is not a digit
is actually correct, given that while "4" and "2" are digits, "42" is NOT.

However, if your intent was to test that the "42" is comprised exclusively of digits, then,

C:\>perl -e "if('42'=~ /^[[:digit:]]+$/) {print qq(42 is exclusively d +igits\n)} else {print qq(42 is not a digit\n)};"
accurately prints:   "42 is exclusively digits"
because the second 1-liner above tests for one_or_more digits.