#!/usr/bin/perl
# fileName, Tag, Value
sub checkFile{
my $fileName = shift;
my $tag = shift;
my $value = shift;
my $endTag = $tag;
substr($endTag,1,0,"/");
my $found = "";
my $re = $tag . "(?:.+?_)?(\\d+?)(?:_.+?)?" . $endTag;
open FILE, $fileName or die $!;
while (my $line = <FILE>){
#print "RE: " . $re . "\n";
$match = $line=~/${re}/;
if($match){
#print $line . $1;
if ($1 != $value){
print "Different:" . $1 . " != " . $value . "\n";
}else{
$found = true;
}
}
}
close FILE;
if (!$found){
print "[ERR] :" . $fileName . "에서 ". $re . " 값을 찾지 못했습니다. \n";
}else {
print $fileName . " 확인 완료 \n";
}
}
$stdFile = "C:\\yourfile.xml";
#print $ncaFile;
$stdValue = "";
open STD_FILE, $stdFile or die $!;
while (my $line = <STD_FILE>){
$match = $line=~/<server>(.+?)<\/server>/;
if($match){
$stdValue = $1;
last;
}
}
close STD_FILE;
if (!$stdValue) {
print "파일에서 기준값을 찾지 못했습니다";
die;
}
print "STD: " . $stdValue . "\n";
$file = "C:\\yourSearchFile.xml";
$tag = "<name>";
checkFile($file, $tag, $stdValue);