#!/usr/bin/env perl use warnings; use strict; my @bc; my %count; while (<DATA>) { my $BankCode = (split /\t/)[0]; $count{$BankCode}++; } for (keys %count) { print "$_ $count{$_}\n" } __DATA__ code1 fooz barz code2 fooz barz code1 fooz barz code3 fooz barz code1 fooz barz code1 fooz barz
prints:
code3 1 code2 1 code1 4
In reply to Re: counting unique elements of an array
by toolic
in thread counting unique elements of an array
by mmittiga17
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |