in reply to Array Ref Loop

You're passing an array reference into the display() function, but within that function, you're not extracting things properly.

You can either do this:

display(@data);

...then change your for loop in the function:

for my $dir (@dirs){ # idiomatic perl way to loop over a list print "$dir\n"; }

If you want to stay with the reference, you must change how you extract the parameter(s), and then dereference the array reference when using it:

sub display { # pull out the aref passed in my $dirs = shift; # could also be `my ($dirs) = @_;` # loop over the aref. Note the syntax # could also be written with the circumfix operator: # @{ $dirs } for my $dir (@$dirs){ print "$dir\n"; } }