will store the 2nd and 3rd digits in $1
only on a 4 digit number. and if you are only dealing with 4 digit numbers then the regex can be more simply written as
. the
sign refers to one or more occurrences of the preceding thing. what you will find is that if you have a number of more than 4 digits your regex will match the third-last and second-last. this is because perl's regexes are "greedy" so the first
will suck up as many digits as it can before backtracking to allow the rest to match. again, this could be more simply written as