The input file file.xml contains some legal xml with root html tag with content in it. I have set the record separator to undef, so that the entire file is slurped into $records as one big line. In the regex match below, I am trying to get the contents of the html element. This works when I use a literal as the input, but not when I use the variable $records as the input to match, I get 'Use of uninitialized value $text in string at... ' at run time. Why? Am I not capturing the result of the match into $text?
use strict;
use warnings;
open FILE_IN, '<file.xml';
open FILE_OUT, '>results.txt';
$/ = undef;
my $records = <FILE_IN>;
my $text = "";
($text) = $records =~ m/<html>(.*)<\/html>/;
print "$text";
close FILE_IN;
close FILE_OUT;
Puzzling.