I need to get a count of how many unique data values I have in my text file.
The text file has data like this:
123 56
123 56
234 45
123 56
678 93
678 93
I need the results of my script to look like this:
234 45 1
123 56 3
678 93 2
Here is my attempt and its not printing any data:
my $file = 'filehere.txt';
open(DATA, "$file") || die "Can not open: $!\n";
my @array = (<DATA>);
close(DATA);
open(DATA, "$file") || die "can t open: $!\n";
my %hash = ();
foreach $item (@array)
{
$hash{$item}++;
}
print "$item\t$hash{$item}\n";
close(DATA);