#!/usr/bin/perl ##BILLING PROGRAM## ##open needed files to use in program open(FILE, "../Counts/data.txt"); open(FILE2, "../Counts/file.csv"); ##throw files into arrays and define arrays @data = <FILE>; @data2 = <FILE2>; ##define hash my %keyhash = ( $id => { NAME => $name, SRID => $srid, CSV => [] } ); ##populate arrays: for ( @data ) { ##define variables my ($id,$name,$srid) = split /,/; # Add some error checking to make sure the # hash key $id does not already exist $keyhash{$id} = { NAME => $name, SRID => $srid, CSV => [], } } ##print unused ids from csv file print "\n\nUnused ids from csv file\n"; print "--------------------------\n"; for ( @data2 ) { my ($id,$name,$srid) = split /,/; # Warn and do nothing if a record is found for which the # $name is not already in %keyhash unless ( defined( $keyhash{$name} ) ) { warn "No such record $id!\n"; next; } push @{$keyhash{$id}{CSV}}, [ $name, $srid ]; } ##Finally, extract the number of records for each customer ##print column headers print "\n\n"; print "Customer #of docs\n"; print "-------------------------\n"; # A little something to get the plurality correct for ( keys %keyhash ) { my $num = @{$keyhash{$_}{CSV}}; printf "%s %d\n", $keyhash{$_}{NAME}, $num, } ##just formatting by adding a couple returns at the end of the printou +t print "\n\n"; ##my choice of data structures ( hashes instead of arrays ) is dependa +nt ##on how we want to use the data later. ##so far this hash is working fine unless I figure out a better way ##close files close FILE; close FILE2; ##exit program exit;
In reply to still confused! by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |