use strict; use warnings; use 5.010; my @inputArray = (1, 2, 3, 4, 5, 6, 7, 8); traverseArray(\@inputArray, 0); sub traverseArray { my ($aRef, $index) = @_; return if $index >= @$aRef; print "$aRef->[$index]\n"; traverseArray($aRef, $index + 1); }