in reply to reset of match variables

You can't reset them without doing a new match, but you can easily check whether there was a match:

perl -ne '/$regex/ and $SUM += $1; END { print $SUM }' file.txt