in reply to Re^2: Opening multiple log files
in thread Opening multiple log files
The builtin glob function will probably do what you want. Just make sure you check the "Portability issues" noted in that document.
Something like:
my @logfiles = glob "*.log";
then just iterate @logfiles, processing each in turn.
Because you said "... all of the files(many) in the same directory ..." you may exceed a maximum size. See GLOB_LIMIT in File::Glob for details.
If you are likely to approach that limit, a better option (although, a bit more coding) would be to use readdir.
You'll need to skip everything except normal files with a .log extension. Something like this (untested):
while(readdir $dh) { next unless -f and /\.log$/; # Process log file here }
See File Test Operators if you're unfamiliar with -f.
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Opening multiple log files
by hahazeeq (Novice) on Jun 15, 2015 at 08:06 UTC | |
by kcott (Archbishop) on Jun 15, 2015 at 08:33 UTC | |
by hahazeeq (Novice) on Jun 15, 2015 at 09:17 UTC | |
by kcott (Archbishop) on Jun 16, 2015 at 02:48 UTC | |
by Anonymous Monk on Jun 15, 2015 at 09:14 UTC |