sub printArray { for my $element ( @_ ) { print $element, "\n"; } } .... my @array = (1 ,2 ,3 4, 5); printArray( @array );