>
Currently Browsing: Perl

Perl: Iterating Through Log Files in a Directory

Perl: Iterating Through Log Files in a Directory
Today I share a Perl snippet to iterate through log files in a specified directory. In this particular case there was a need to parse the log files, ignoring previously compressed files. The file names were in the format of: file.log file.log.1 file.log.2 file.log.3.gz file.log.4.gz … file.log.10.gz Though the file names could go up to *.99, we didn’t know which, if any, would be compressed. Obviously using “*.log” wouldn’t get the *.1 or *.2 files and using “*.log*” picked up the compressed files. The solution was to use “glob” with a couple...
read more