@ARGV = glob '/export/home/date_file*';
####
while ( my $line = <> ) {
####
#!/usr/bin/perl
use warnings;
use strict;
use List::Util qw(sum);
# Grab text files from archive directory with glob function
my @files = glob '/export/home/date_file*';
my %counts = (
AB => 0,
AC => 0,
AD => 0,
AE => 0,
FG => 0,
);
for my $file (@files) {
open my $fh, '<', $file
or die "$file: $!";
while ( my $line = <$fh> ) {
my $var = substr $line, 41, 2;
$counts{ $var }++ if exists $counts{ $var };
}
close $fh
or die "$file: $!";
}
my $sum = sum values %counts;
for my $type ( keys %counts ) {
print "$type\t: $counts{$type}\n";
}
print "Total \t: $sum\n";