#! perl -slw use strict; my( $target_name, %probes ); $_ = ; # Prime the pump. do { # extract the target name $target_name = $1 if m[( \d{7} ) _at: \d{3} : \d{3} ]x; while( m[$target_name] ) { # process the record containing the current target name my $probe = ; # Read the probe chomp $probe; # save it in an HoA keyed by the target name push @{ $probes{ $target_name } }, $probe; last unless defined( $_ = ); # get the next line; } } until eof DATA; # till done print $_, ' : ', join', ', @{ $probes{ $_ } } for keys %probes; __DATA__ probe:MOE430A:1415670_at:549:177; Interrogation_Position=2513; Antisense; GAGGAAACGTTCACCCTGTCTACTA probe:MOE430A:1415670_at:467:433; Interrogation_Position=2521; Antisense; GTTCACCCTGTCTACTATCAAGACA probe:MOE430A:1415670_at:254:643; Interrogation_Position=2533; Antisense; TACTATCAAGACACTCGAAGAGGCT probe:MOE430A:1415670_at:54:269; Interrogation_Position=2556; Antisense; CTGTGGGCAATATTGTGAAGTTCCT probe:MOE430A:1415670_at:405:339; Interrogation_Position=2583; Antisense; GAATGCATCCTTGTGAGAGGTCAGA probe:MOE430A:1415670_at:60:395; Interrogation_Position=2597; Antisense; GAGAGGTCAGACAAAGTGCCAGAAA probe:MOE430A:1415670_at:284:165; Interrogation_Position=2619; Antisense; AAAACAAGAACACCCACACGCTGCT probe:MOE430A:1415670_at:622:145; Interrogation_Position=2634; Antisense; ACACGCTGCTGCTAGCTGGAGTATT probe:MOE430A:1415670_at:291:661; Interrogation_Position=2804; Antisense; TATCTTGTCCAACACTACGTCGAAG probe:MOE430A:1415670_at:146:701; Interrogation_Position=2956; Antisense; TTGTCACCATGCCTGCAAGGAGAGA probe:MOE430A:1415671_at:116:525; Interrogation_Position=1156; Antisense; GGAACAGGAATGTCGCAACATCGTA probe:MOE430A:1415671_at:655:137; Interrogation_Position=1173; Antisense; ACATCGTATGGATTGCTGAGTGCAT probe:MOE430A:1415671_at:398:139; Interrogation_Position=1232; Antisense; GGCTGATCACATCCAAAAAGTCATG