use warnings; use strict; my @arr = qw (J K L M N O); print join (' - ', splice @arr, 0, 2), "\n" while @arr;