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
In reply to Re: Split at specific spaces
by johngg
in thread Split at specific spaces
by perl_search_m
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |