in reply to how to empty the built_in variable

In the above code the second line should not have any value in $1

Actually, that's not true. The behaviour that you are seeing is documented in perlre.

NOTE: failed matches in Perl do not reset the match variables, which makes it easier to write code that tests for a series of more specific cases and remembers the best match.