in reply to Regular Expression XML Searching Help

In your loop "foreach my $file (@files)" -- $file will have the name of the XML file, not the contents of the file. As mentioned above, you need to read the contents of each file and use the s modifier on the regex to make the . match newlines:
my $xml_dir = "c://temp"; opendir(DIR, $xml_dir); my @files = grep { /\.xml$/ } readdir(DIR); closedir(DIR); foreach my $file (@files) { open my $fh, "$xml_dir//$file" or die "can't open $file: $!"; local $/; my $contents = <$fh>; close $fh; print "$file is "; if($contents !~ /<order>(.*)<\/order>/s){ print "NOT "; } print "valid\n"; }
Results:

invalid.xml is NOT valid #this is your sample file 2

valid.xml is valid #this is your sample file 1