0

How do I recursively include subdirectories in an array using glob?

I currently have my @files = glob $PATH . '/*'; (where $PATH = ".") but this does not include subdirectories.

Bijan
  • 7,737
  • 18
  • 89
  • 149
  • Re. *"Unfortunately, even though $WatchSubTree is set to 1, it cannot seem to monitor subdirectories."* This may just be a typo, but whether your `@files` array includes subdirectories has nothing to do with whether `Win32::ChangeNotify` is monitoring them. – ThisSuitIsBlackNot Mar 18 '15 at 19:20
  • 1
    I realized afterwards that my question was _solely_ about the `@files` array and not about ChangeNotify. I have modified the question accordingly. – Bijan Mar 18 '15 at 19:21

2 Answers2

1

I found my answer from Here

I just changed @files to be my @files = File::Find::Rule->in($PATH);

Community
  • 1
  • 1
Bijan
  • 7,737
  • 18
  • 89
  • 149
1

If you like to stick with standard modules you can use this code.

use strict;
use warnings;
use File::Find;

my @files;
find( { wanted => sub { push @files, $_ }, no_chdir => 1 }, $PATH );
Hynek -Pichi- Vychodil
  • 26,174
  • 5
  • 52
  • 73