# 1A. not very anal, but more concise for my $dir (glob "*") { # for a brief moment, $dir might not hold a directory's name next unless -d $dir; ... } #### # 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; ... } #### # 1C. more "correct", with additional variable and concept for my $entry (glob "*") { next unless -d $entry; my $dir = $entry; ... } #### # 2A. not very anal sub load { # actually, module can be in the form of "Foo::Bar" or "Foo/Bar.pm". # but will be canonicalized to "Foo/Bar.pm" form my $module = shift; if ($module =~ /\A\w+(::\w+)*\z/) { $module = join("/", split /::/, $module) . ".pm"; } ... } #### # 2B. sub load { my $arg = shift; my $module_pm; if ($arg =~ /\A\w+(::\w+)*\z/) { $module_pm = join("/", split /::/, $arg) . ".pm"; } else { $module_pm = $arg; } ... }