Me too... I thought you had some escaping problem here, but no. The code in the OP works as intended.
while (<DATA>) {
s/size="10">##ili(\d{1,2})/size="10" text-anchor="end">##ili$1/g;
print;
}
__DATA__
size="10">##ili7
size="10">##ili56
size="10">##iliad
As expected, this prints out
size="10" text-anchor="end">##ili7
size="10" text-anchor="end">##ili56
size="10">##iliad
I.e. it does the replacements on the first two lines, and skips the third as it has a letter instead of a number after the ##ili. I'm not sure what your problem is, perhaps your data isn't as uniform as you thought it was: the source file has variants of the string with whitespace etc. and some of these are not matched by the regex.