#!/usr/bin/perl -w
use strict;
use File::Find;
use HTML::TokeParser;
##Here define the directory to work across
my $root_dir = 'c:/test1';
##Search the directory, when a file is found run the sub.
find(\&wanted, $root_dir);
sub wanted {
# if the extension fits...
if ( /(LOG[^\n]*)|(REC[^\n]*)\.xml?/i ) {
##Grab the filename for error to screen if cannot open.
my $input = $_;
open (OUTPUT, ">>c:\\1-Actnte.txt");
open INPUT, "$input" or die "Cannot open $input";
select OUTPUT;
$\ = "\n";
my $foundstart;
while () {
chomp;
next unless ($foundstart || /]*>/i);
while (/]*>/i && ! $foundstart) {
$_ =~ s/^.*?]*>$/\n|i) {
$_ =~ s|^(.*?).*$|$1|i;
print if($_);
last;
}
print;
}
close INPUT;
}
}
close OUTPUT;