in reply to Split at specific spaces
Yet another way using split on spaces but with a capture so the spaces are retained. Discard every 6th element then join five at a time.
$ perl -E ' > $_ = q{1 AC2 34 TRP A 6 ALA A 7 ILE A 14 GLY A 15}; > @e = grep { ( ++ $i ) % 6 } split m{(\s+)}; > say join q{}, map { shift @e } 1 .. 5 while @e;' 1 AC2 34 TRP A 6 ALA A 7 ILE A 14 GLY A 15 $
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Split at specific spaces
by k_manimuthu (Monk) on May 12, 2010 at 09:26 UTC | |
by toolic (Bishop) on May 12, 2010 at 12:46 UTC |