Code:
$ cat infile
51176,qsc,/ureports/fusqsc/stmt,/home/dslmain/qsc/scripts/copylsoftosftpwithmove.sh,qscsftp@sftp1: prod/qsc/dsi/xml,EXPORT,<where>7862<any>DSI<any>.xml,YES
120004,bns,dslmain@faunus:import/svc,/home/dslmain/bns/scripts/copylsoffromsftpnomove.sh,/ureports/exportbns/svc,IMPORTNOMOVE,<where>fndmut<any>.svc,NO
120006,gjv,/ureports/exportbns/extracts/sent,/home/dslmain/bns/scripts/copylsoftosftp.sh,bnssftp@sftp1: prod/bns/export/extracts,NO,<where><any><yesterday>,NO
120007,bns,dslmain@faunus:import/svc,/home/dslmain/bns/scripts/copylsoffromsftpnomove.sh,/ureports/exportbns/svc,IMPORTNOMOVE,<where>fndmut<any>.svc,NO
120008,fid,/ureports/ibfid/jot/rpts/nofiche,/home/dslmain/fid/scripts/copylsoftosftp.sh,fidsftp@sftp1: prod/fid/jot/rpts/nofiche,YES,<where><any><yesterday><any>,NO
$ cat script.pl
use warnings;
use strict;
my (%client_data, $num_clients);
while ( my $line = <> ) {
my ($rule, $client) = split /,/, $line;
++$num_clients;
push @{ $client_data{ uc $client } }, $rule;
}
printf qq[Rules changed for %d clients: %s\n],
$num_clients,
join qq[, ],
map {
@{ $client_data{ $_ } } > 1 ?
$_ . qq[ x] . scalar @{ $client_data{ $_ } }
:
$_ }
keys %client_data;
printf qq[The total number of Rules changed are: %d\n], $num_clients;
for ( keys %client_data ) {
printf qq[Rules changed for %s: %s\n],
$_,
join qq[, ], @{ $client_data{ $_ } };
}
$ perl script.pl infile
Rules changed for 5 clients: QSC, FID, GJV, BNS x2
The total number of Rules changed are: 5
Rules changed for QSC: 51176
Rules changed for FID: 120008
Rules changed for GJV: 120006
Rules changed for BNS: 120004, 120007