in reply to File name search with regex
Update: I misread the OP as NOT wanting L|Log files (I'm leaving my OP below as-is/original). RichardK's response here is the better one. He also taught me about the mtime method, so at least I learned something :) /update
Hi oldenuf2no, welcome to the PerlMonks Monastery!
File::Find::Rule will help clean up your code, the -M flag can do the check, and throw in a tiny regex to bypass files that start with L or Log and you end up with this:
use warnings; use strict; use File::Find::Rule; my $dir = '.'; my @files = File::Find::Rule->file()->name('*')->in($dir); for (@files){ if (-M $_ > 5 && $_ !~ /^(?:L|Log)/){ print "$_\n"; } }
-stevieb
|
|---|