#!/usr/bin/perl use strict; use Data::Dumper ; my $str = `bpdbjobs`; my $filename = 'bpdbjobs.txt'; open(FH, '>', $filename) or die $!; print FH $str; close(FH); open(FH, '<', $filename) or die $!; my $fmt = 'A5 A15 A1 A7 A6'; my %counts = (); my @col = ('JobID','Col2','Type','State', 'Status','Policy','Schedule','Client', 'Dest Media Svr','Active PID'); # 10 cols my $totalfails = 0; while (){ next unless /\S/; # skip blank lines next if /^\s+JobID/; # skip header chomp; my @f = unpack $fmt,$_; s/^\s+|\s+$//g for @f; # trim spaces # count each column for my $n (0..$#col){ ++$counts{$col[$n]}{$f[$n]}; } print join "\|",@f,"\n"; # check } $totalfails += $counts{'Status'}{$_} for grep {$_ > 1} keys %{$counts{'Status'}}; print Dumper \%counts; printf "Statistic.SUCCESSFULL = %d\n",$counts{'Status'}{'0'}; printf "Statistic.PARTIAL = %d\n",$counts{'Status'}{'1'}; printf "Statistic.FAILS = $totalfails\n"; close(FH);