in reply to Re^2: How to get sub-folder names using perl?
in thread How to get sub-folder names using perl?
Hello erhan,
(1) In Perl there are two ways to concatenate strings:
In the present case, my $result_path = $dir . '/results'; has the same effect as my $result_path = "$dir/results";, so the choice between them is merely stylistic. But as a general rule, it’s best to avoid double-quote interpolation if you don’t need it: see Whats-wrong-with-always-quoting-vars of perlfaq4.
(2) The line next unless -d $subdir; causes the foreach loop to skip to the next iteration (i.e., to ignore the current value of $subdir) unless the current $subdir is a directory (and not a file, a symbolic link, etc.). It uses the -d function which is documented in functions/-X.
(3) The line chdir $dir . '/' . $subdir; contains two more concatenation operators, and is equivalent to:
chdir "$dir/$subdir";
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|