I'm trying to make a simple script in perl that will look for obvious errors in an xml file. I figured the best way to accomplish this is to create a regular expression and have perl use it to return bad lines of xml. Here is my code
#!/usr/bin/perl
$file = '/path/to/my/xml/file.txt';
open(txt, $file);
while($line = <txt>) {
print "$line" if $line =~ m/<[a-zA-Z]*>[$a-zA-Z0-9]*>[a-zA-Z0-9]*</;
}
close(txt);
The regex I'm using works perfectly in notepad++ but when I put it in perl it doesn't want to work. I'm trying to find a line of xml that looks like this
<tag>badline></tag>
if I break apart my regex lines get returned.
m/<[a-zA-Z]*> -works
[$a-zA-Z0-9]*> -works
[a-zA-Z0-9]*</; -works
but when I combine them like I showed in the code, it doesn't
Any help is greatly appreciated, thanks.