#!/usr/bin/perl -w use strict; my $log = './log'; my %count; open (LOG, $log) or die "Can't open $log: $!"; while (){ my ($dst, $service) = (split /;/)[11, 12]; $count{$_}++ for $dst, $service; # Now I see it this way, I realise that # $count{$_}++ for (split /;/)[11, 12]; # would be even better :) } print map "$_ appears $count{$_} times\n", keys %count;