home *** CD-ROM | disk | FTP | other *** search
- #
- # check_id.pl
- #
- # The program
- # takes 'ent.xml' file from near self and gets info about entity files
- # opens entity file in ENT folder and gets info about current entity in the file
- # generate XML, XSL and HTM files in corresponding folders
- #
- #
- # Comment:
- #
-
- $qwe='"';
- $reshetka='#';
- $nbsp=' ';
-
- local $dir = "newfolder/";
- local $file;
- local $err = "err.txt";
-
- local $stringline;
- local $id;
- local @idArr = ();
-
- @file=glob("newfolder/*.xml");
-
- open(ERR, ">$err") || die "can't open $err: $!";
-
- foreach $file (sort @file)
- {
- open(FILE, $file) || die "can't open $file: $!";
- while (defined ($stringline = <FILE>))
- {
- if ($stringline =~ /<item / || $stringline =~ /<section /)
- {
- $id = &getAttrValue($stringline,'id');
- push (@idArr, $id);
- }
- }
- close(FILE);
-
- print ERR "$file\n\n";
- for ($i=0; $i<$#idArr+1; $i++)
- {
- for ($j=$i+1; $j<$#idArr+1; $j++)
- {
- if ($idArr[$i] eq $idArr[$j])
- {
- print ERR "$idArr[$i]\n";
- print "$idArr[$i]\n";
- }
- }
- }
- print ERR "\n";
- @idArr = ()
- }
-
- close(ERR);
-
- print "All Done!..";
- <>;
-
-
-
-
- # sub function sections
- # getAttrValue: return value of attribute from the string
- sub getAttrValue
- {
- local ($attrStr,$attr) = @_;
- local @attrArr = ();
- local $attrVal;
-
- $attrStr =~ s/<//;
- $attrStr =~ s/>//;
-
- push (@attrArr, split /\s+/, $attrStr);
-
- for ($i=0; $i<$#attrArr+1; $i++)
- {
- if ($attrArr[$i] =~ /$attr/)
- {
- $attrVal = $attrArr[$i];
- $attrVal =~ s/.*${attr}="(.*)".*/\1/;
- }
- }
- return $attrVal;
- }
-