8 |
use Data::Dumper; |
use Data::Dumper; |
9 |
use XML::Simple; |
use XML::Simple; |
10 |
use Fcntl; # For O_RDWR |
use Fcntl; # For O_RDWR |
11 |
use NDBM_File; |
use DB_File; |
12 |
|
|
13 |
my $config_file; |
my $config_file; |
14 |
|
|
36 |
my $dbm = $config->{dbm} || die "config: no <dbm> defined"; |
my $dbm = $config->{dbm} || die "config: no <dbm> defined"; |
37 |
|
|
38 |
my %dbmhash; |
my %dbmhash; |
39 |
tie %dbmhash, "NDBM_File", $dbm, O_RDWR, 0666 || die "tie: can't tie to '$dbm': $!"; |
dbmopen %dbmhash, $dbm, 0666 || die "tie: can't tie to '$dbm': $!"; |
40 |
|
|
41 |
my $rfc = new SAP::Rfc( |
my $rfc = new SAP::Rfc( |
42 |
ASHOST => $config->{sap}->{ashost}, |
ASHOST => $config->{sap}->{ashost}, |
50 |
|
|
51 |
$rfc->is_connected || die "FATAL: SAP not connected"; |
$rfc->is_connected || die "FATAL: SAP not connected"; |
52 |
|
|
|
print STDERR "Using '$indir' as input directory...\n"; |
|
|
|
|
53 |
opendir(DIR, $indir) || die "can't opendir $indir: $!"; |
opendir(DIR, $indir) || die "can't opendir $indir: $!"; |
54 |
my @files = grep { !/^\./ && -f "$indir/$_" } readdir(DIR); |
my @files = grep { !/^\./ && -f "$indir/$_" } readdir(DIR); |
55 |
closedir DIR; |
closedir DIR; |
57 |
print LOG scalar localtime," Found ",$#files+1," files in directory...\n"; |
print LOG scalar localtime," Found ",$#files+1," files in directory...\n"; |
58 |
|
|
59 |
foreach my $file (@files) { |
foreach my $file (@files) { |
60 |
if ($dbmhash{$file}) { |
if (exists $dbmhash{$file}) { |
61 |
|
print STDERR scalar localtime," Skipping file '$file'\n"; |
62 |
|
} else { |
63 |
print LOG scalar localtime," New file '$file', processing...\n"; |
print LOG scalar localtime," New file '$file', processing...\n"; |
64 |
$dbmhash{$file}++; |
$dbmhash{$file}++; |
|
} else { |
|
|
print STDERR scalar localtime," Skipping file '$file'\n"; |
|
65 |
} |
} |
66 |
} |
} |
67 |
|
|