summaryrefslogtreecommitdiff
path: root/examples/printer-accounting/acct-sum
blob: ffbfc8d8801f4459555d68f6ca6690d60884bad0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl

while (<>) {
        ($date, $user, $machine, $size, $pages) = split(' ');

        $Printer{$ARGV}++;
        $PrinterPages{$ARGV} += $pages;

        $Jobs{$user}++;
        $Size{$user}+= $size;
        $Pages{$user}+= $pages;
}

printf "%-15s %5s %8s %8s\n", qw(User Jobs Pages Size);
foreach $user (sort keys %Jobs) {
        printf "%-15s %5d %8d %8d \KB\n",
                $user, $Jobs{$user},  $Pages{$user}, $Size{$user}/1024;
}


print "\n\n";
printf "%-15s %5s %8s %8s\n", qw(Printer Jobs Pages);
foreach $prn (sort keys %Printer) {
        ($name = $prn) =~ s=.*/==;
        printf "%-15s %5d %8d\n",
                $name, $Printer{$prn}, $PrinterPages{$prn};
}