I have a program expecting input from stdin, OR from a mix of .log and .log.gz files. Here are the three types of calls I want the program to handle:
cat input.log | prog
prog < input.log
prog input.log input.log.gz
The program considers all input files as one. I was hoping to capitalize on ARGV to process all input uniformly:
while (<>) {
# process input
}
My goal is to process gz files in the same loop. How can this be done? I want to know how messy it is. If it is too bad I will handle gz separately.
I can only use core modules with Perl 5.8.8.
You can’t really do that and get the shorthand benefit of the diamond operator.
openthe files yourself.You might be able to use
@ARGVfor this, but you’ll only get the easy handling if you reopen*::STDINfor these files.