# 1B. more "correct", with additional related variable for my $dir0 (glob "*") { # a "0" suffix is my convention for variables that contain an unprocessed value next unless -d $dir0; my $dir = $dir0; ... }