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