# Open the acct file, and build a hash of hashes to operate on # the outer hash will be built on the job number to reconcile # multiple tries on a single job. The inner hashes will contain # job information. open ACCT, "+<$ARGV[0]"; while (){ chomp; if (/^START.*'j=0?0?(\d+)'.+'D=(\d+)'/){ $jobs{$1}{start_string} = $_; $jobs{$1}{start_date} = $2; } if(/^[a-z]*start.*'-p(\d+)'.+'-A.+\+(\d+)'/){ $jobs{$2}{start_counter} = $1 if $jobs{$2}; } if(/^[a-z]*end.*'-p(\d+)'.+'-A.+\+(\d+)'/){ $jobs{$2}{end_counter} = $1 if $jobs{$2}; } if(/^END.*'j=0?0?(\d+)'/){ delete $jobs{$1} if $jobs{$1}; } } close ACCT; #print Dumper(%jobs); # Operate on the hash. reconcile jobs, and put appropriate entries # into the acct file to forestall further charging. #foreach $job (sort { $jobs{$job}{start_date}<=>$jobs{$job}{start_date} } keys %jobs){ foreach $job (sort {$jobs{$job}{start_date}<=>$jobs{$job}{start_date}} keys %jobs){ print "Job: $job\n"; print " Start Date: $jobs{$job}{start_date}\n\n"; }