in reply to counting unique elements of an array

Not sure why yours isn't working, but is this what you're looking for?
#!/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