my %count; $count{(split /\//)[2]}++ while ; printf "%s = %d\n", $_, $count{$_} for keys %count; __DATA__ //word.one.team/other.stuff/Info.info //this.sentence/other.inforation/moreInfo //first.part.here/set.list //this.sentence/data/processing