http://www.perlmonks.org?node_id=973551

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear fellow Monks,

I have a list with three columns. The first one contains a list of IDs,second different values and third a value or blank (its A\t1_x\tblank). The ID is being repeated many times with different or same values. Example

A 1_x 9_z A 1_x A 1_x g_z B 2_c B 1_x 1_z C 1_x 1_z C v_x 8_z

What I would like to get is a list of IDs with corresponding number of 1_x and any non blank value in third column. So from the above example A 3,2 B 1,1 C 1,2. The list is preaty long so I though maybe I should go line by line append to hash and get the number of 1_x and any non blank string in third column? I started with appending the values in three arrays replacing blanks with NA (thought it might help). How should I tackle this to only go through the list once and not for each ID? Thanks for help