in reply to how to empty the built_in variable

Change the regex line to:

next unless $line =~ /\s+<\w+\/?>(.*)<\/\w+>/;

If the regex fails then $1 is not altered (as you noticed).

Why did you comment out use strict; btw? Your code is fine with strictures enabled.


DWIM is Perl's answer to Gödel