#!/usr/bin/perl use strict; use Getopt::Long; use Data::Dumper; use IO::File; &GetOptions( 'd|date=s' => \(my $DATE), 'p|path=s' => \(my $PATH), 'h|help' => \(my $HELP) ); usage() if defined $HELP or ! (defined $DATE || defined $PATH); $PATH = "/Ack/$DATE" unless defined $PATH; my $ftpoutbound = "/homes/ftpoutbound.db"; my @FileList; opendir (DIR, $PATH) or die "Can't open dir $PATH $!"; while (my $f = readdir(DIR)) { next if -d $f; push @FileList, $f; } closedir DIR; # print Dumper(\@FileList); my %data; foreach my $file (@FileList) { my $f = new IO::File "$PATH/$file", "r" or die ("can't open $PATH/$file :$!"); while (<$f>) { my @rec = split /[\|\*~]/; if ($rec[5] eq "ZZ") { my $id = $rec[6]; $id =~ s/\s+//; $data{$id}{COUNT}++; } } } # print Dumper(\%data); # merge data into %data structure with values from FTP file my $f = new IO::File "$ftpoutbound", "r" or die "can't open $ftpoutbound :$!"; while (<$f>) { chomp; my @ftp_fields = split /;/; if (exists $data{$ftp_fields[0]}) { $data{$ftp_fields[0]}{TRANSPORT} = $ftp_fields[7]; } } undef $f; # display the results foreach (sort keys %data) { printf "%s|%s|%s\n", $_, $data{$_}{COUNT}, $data{$_}{TRANSPORT}; } sub usage { print <