Make it clear that the brackets themselves aren't part of the %[number]N format.
The multi-line qq|...| seems to confuse cperl-mode badly - change to <<EOF here-doc.