#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::BrowseEntry;
use POSIX 'mktime';
use POSIX 'strftime';
open(STDERR, ">&STDOUT");
######## entry widget to get $yyyy $mmm $dd #######################################
print "\n Select Year = $yyyy\n";
print "\n Select Month = $mmm\n";
print "\n Number of Backup Days = $dd\n";
######## create input and output files #######################################
my $filerror = "\n\n! Cannot open File below, please check it exists or is not open already?\n";
my $OUTFILE = "C:\\Temp\\$yyyy\$mmmAudit.txt";
my $INFILE1 = "c:\\$yyyy\\$mmm\\report.csv";
my $INFILE = "c:\\$yyyy\\$mmm\\names.csv";
#Open input file for reading and Output file for writting
open (INPUT,"$INFILE") or die "\n$filerror\$INFILE",,1;
#open (OUTPUT,">$OUTFILE") or die "\n$filerror\n$OUTFILE",,1;
my $total_names = 0;
$total_names++ while ();
my $Month_total = $total_names * $dd;
######### get total number of rows in files ##################################
print "\n Total number of names is $total_names\n";
print "\n Total number of names is $Month_total\n";
close INPUT;
open (INPUT,"$INFILE") or die "\n$filerror\$INFILE",,1;
######### keep only unique names and display number count of duplactes #########
my %seen;
while ()
{
chomp;
my $line = $_;
my @elements = split (",", $line);
my $col_name = $elements[1];
print " $col_name \n" if ! $seen{$col_name}++;
}
close INPUT;