use strict; use warnings; my $s = "foo bar baz qux 3 3 1 3"; my @a = split /\s/, $s; splice(@a, 0, 4); while (@a) { print (shift @a), (shift @a), "\n"; } #### 33 13 #### 31 # and no newline!