#!/usr/bin/perl -w use strict; use Data::Dumper; # need to split up this array and send three values at a time to # sub "do_someting" my @array = qw( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ); while (@array) { my @array_segment; # if element isn't defined, don't get the NULL values push @array_segment, shift @array; push @array_segment, shift @array if defined $array[0]; push @array_segment, shift @array if defined $array[0]; do_something(@array_segment); } sub do_something { my @array = @_; print Dumper \@array; }