#!/usr/bin/perl -w use strict; my @arr = (1..15) ; my ($offset,$offset1) ; $offset = $offset1 = int((scalar @arr)/3); $offset++ if (scalar @arr % 3 > 0) ; $offset1++ if (scalar @arr % 3 > 1) ; my ($arr1, $arr2, $arr3) = ([@arr[0..$offset-1]],[@arr[$offset..$offset+$offset1-1]],[@arr[$offset+$offset1..scalar @arr -1]]); print $_."\n" for ((@$arr1,("\n"),@$arr2),("\n"),@$arr3);