in reply to Re: Filename Template
in thread Filename Template

Abstraction,
To expound on what you have said:
#!/usr/bin/perl -w use strict; use File::Find::Rule; my @files = File::Find::Rule->file() ->name( qr/^[a-zA-Z]{4}-\d{8}/ ) ->in( / );
It appeared at first in the docs that all you could do was file globs, but later on I saw a regex, so I think this will work.

Cheers - L~R

Update: Bah, broquaint beat me to it, so yes it will work. What's worse - his solution provides the ability to modify the template without modifying the regex. I guess the only thing I would have done differently is changed the character class to [a-zA-Z] instead of using /i for speed reasons - but if it runs a tad bit slower it just means you can go get more caffeine.

Replies are listed 'Best First'.
Re: Re: Re: Filename Template
by l2kashe (Deacon) on Aug 07, 2003 at 15:26 UTC

    even a simple readdir should do the trick

    #!/usr/bin/perl -w use strict; my $dir = '/some/dir'; my $file_re = qr/^(?:\.+|[a-zA-Z]{4}-[0-9]{8})$/; opendir(DIR, $dir) or die "opening $dir: $!\n"; for ( grep(!/$file_re/, readdir(DIR)) ) { # deal with non conforming file names here } closedir(DIR);

    use perl;