You need to split each input line or otherwise extract the 2 items from it. Here is an SSCCE:
#!/usr/bin/env perl use strict; use warnings; my %count; while (my $line = <DATA>) { my ($key, $field) = split / +/, $line; push @{$count{$key}}, $field; } for my $key (sort keys %count) { print "$key ---> " . scalar @{$count{$key}} . "\n"; print $_ for @{$count{$key}}; print "\n"; } __DATA__ 0011 Sally 1122 Brandon 2233 George 0011 Roy 1122 Simson
🦛
In reply to Re: Frequency occurence of same words in a file
by hippo
in thread Frequency occurence of same words in a file
by geek12
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |