use strict; use warnings; use Test::More; sub chunks { my $str = ""; while (my @cols = splice @_, 0, 3) { $str .= "@cols\n"; } return $str; } # ========= Tests my @list = ("a", "bb", "c", "d", "e", "f", "g", "h"); my @old = @list; my $text = "a bb c\n" . "d e f\n" . "g h\n" ; is( chunks(@list) => $text, "Rosetta's Example"); is( chunks() => "", "Empty string" ); is( chunks("") => "\n", "Empty List" ); is_deeply( \@list, \@old, "Non destructive! yeah ... :)"); done_testing;