Hi there,
if you want to learn try think before ask ^_^ OK
now you can try this code as it worked with me, I put sample data in test file $File_Name = 'data.txt'
#!/usr/bin/perl -w
use strict;
use warnings;
my $File_Name = 'data.txt';
my %Aggr;
open(FH, "< ./$File_Name") or die "couldn\'t open [$File_Name]\n".$!;
my @Data = <FH>;
foreach my $line(@Data){
my @tmpRaw = split / /, $line;
foreach my $Item(@tmpRaw){
chomp($Item);
$Aggr{$Item}++;
}
}
foreach my $key (sort keys %Aggr){
print $key.":".$Aggr{$key}."\n";
}
close(FH);
|