http://www.perlmonks.org?node_id=125312


in reply to Dir Structure Print out

In addition to the other comments above, I would like to make the following two small additional comments:

  1. There is a great potential for an endless recursive loop to be established if your program processes a symbolic link to a directory higher in the directory tree - This is a common trap that File::Find-like subroutines get caught by. To correct this, simply add a negative test for symbolic link with your -d test. ie.

    if (-d $dir && !-l _) { ... };
  2. And less importantly, the sort by_lc readdir(DIR) block in the op_dir subroutine could more easily be written as thus:

    foreach (sort { lc($a) cmp lc($b) } readdir(DIR)) { push (@dir, "$dir\/$_") if (m/$non_include/); };

 

Ooohhh, Rob no beer function well without!