in reply to Re-organising entries
Here's my approach (reading from DATA instead of a file handle for convenience):
use strict; use warnings; while (<DATA>) { chomp; my ($id, @records) = split /\t|(?<=\)),\s+/, $_; my (@left, @right); for my $r (@records) { if ($r =~ /^SP_/) { push @left, $r; } else { push @right, $r; } } while (@left || @right) { print $id, "\t", (shift(@left) || ' - '), ', ', (shift(@right) || ' - '), "\n"; } } __DATA__ 1 SP_85(IS33, qqq), SP_155(IS33eee) spr_111(ISyyy33, qqq), spr_1 +71(IS33eee) 2 SP_83(S3 , jgjg), SP_32(IS33, jhdjdjd) spr_113(Stty3 , jgjg), +spr_1881(IS33, jhdjdjd) 3 SP_78(3jmdsjkdej), SP_66(IShbdhdhd33) spr_115(3jmhhggggdsjkdej +), spr_1551(IShbdhdjjjhd33), spr_88881(Iyt33ff), spr_145411(Iddd3ff) 4 SP_77(3jmdsjkdej), SP_1485(Idhd33ff) spr_116(3jmdhhhhhsjkdej), + spr_17781(Idhdhhtytyt33ff)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Re-organising entries
by $new_guy (Acolyte) on Feb 14, 2011 at 15:12 UTC |