use strict;
use warnings;
use XML::Twig;
use File::Spec;
use POSIX qw(strftime);
my $spec_text = qr/^SLD/;
my $path_tmp = $0;
(my $volume,my $directories,my $file) = File::Spec->splitpath( $path_t
+mp );
my $path = $volume . $directories;
opendir (DIRREN, $path) || die ;
my @RENDIR = readdir (DIRREN);
close (DIRREN);
shift(@RENDIR);
shift(@RENDIR);
open(OUT,'>','out.txt');
foreach my $file (@RENDIR) {
if ($file =~ $spec_text){
my $mode = (stat($file))[9];
my $file_date = strftime "%Y%m%d", (localtime($mode));
my $file_date_ref = \$file_date;
my $file_ref = \$file;
XML::Twig->new( # the twig will only contain PHONENO/ENTRY and
+ REASON/ENTRY elements
# (plus the root or it would not be a tree)
twig_roots => { 'BL_USER/PHONENO/ENTRY' => 1,
'BL_DPLI_RECORD/REASON/ENTRY'
+=> \&reason,
'BL_DPLI_RECORD/BL_DP_DUNNED/M
+ONETARYVALUE/V' => 2,
}
)
->parsefile($file);
sub reason
{ my( $t, $reason)= @_;
foreach my $phone_no ($reason->prev_siblings)
{ print OUT $phone_no->text , ";" , $reason->text , ";
+" , $$file_ref , ";" , $$file_date_ref ,";",$reason->next_siblings, "
+\n"; }
$t->purge;
}
}
}
close(OUT);