Not addressing your direct question, but since you seem to be trying to parse something that looks vaugely like XML, have you considered using a real parser?
#!/usr/bin/perl -l
use strict;
use warnings;
use XML::Simple;
my $xml = XMLin(\*DATA);
print for @{ $xml->{tag} };
__DATA__
<xml>
<tag>This is a line</tag>
<tag>This one goes
over multiple lines</tag>
</xml>