in reply to Simple perl counter
It assumes you only want unique ids counted - it is much easier if that is not the case : $data{$name}++#!/usr/bin/perl use strict; use warnings; my $file = $ARGV[0] || 'input.txt'; open (INPUT, '<', $file) or die "Unable to open $file for reading : $! +"; my %data; while ( <INPUT> ) { chomp; my @info = split /\|\|/; push @{$data{$info[3]}}, $info[1] if ! $data{$info[3]} || ! grep / +^$info[1]$/ , @{$data{$info[3]}}; } for my $id ( keys %data ) { print "$id : " , scalar @{$data{$id}}, "\n"; }
Cheers - L~R
|
|---|