| Next | The Identity Function | 35 | 
walk_tree is a great tool
Like File::Find, only not as bloated and inconvenient
But you need some trivial functions to use it properly
We already saw:
        walk_tree($DIR, sub {push @FILES, $_[0]}, sub {});
Here's another one:
        sub dangling_link { -l $_[0] && ! -e $_[0] }
        @dangling_links = 
          walk_tree($DIR, sub { &dangling_link ? ($_[0]) : () }, 
                          sub { @_ }         # Identity function
                   );  
The sub { @_ } here is an accumulation function
It takes the lists that were returned for the subdirectories and returns one big list
| Next |  | Copyright © 2001 M. J. Dominus |