Do not use
$1 except after you've verified that the match was successful,
else you will get the
previous $1. That would not have been
fatal here, but if you'd been accumulating rather than setting, you'd get some
odd stuff.
-- Randal L. Schwartz, Perl hacker