note
graff
Well, I'm not in a position to test it myself, so I have to ask you: Have you tried running it, and does it do what you want?
<P>
As for improvements, I can think of several, but if the script works, these are less than crucial -- well, except for the fact that you really should include "use strict", and learn about scoping variables.
<P>
Apart from that, in no particular order:
<UL>
<LI> You have "use PerlIO::gzip" at the top, but you never actually use the ":gzip" IO layer. You're just running "zgrep" in backticks.<P>
<LI> Actually, looking at the zgrep command line in the backticks, I don't see you providing an input file name there -- just a pattern to search for. I would expect the resulting output files to be empty every time.<P>
<LI> You appear to be generating 14 output files for every input file. Is that really what you want? You never actually say what the goal is here, but fourteen separate output files for each input file seems like a lot.<P>
<LI> You can simplify and improve your handling of command line options and args. Take a look at [cpan://Getopt::Std] and [cpan://Getopt::Long] -- these are part of the core distribution; also, the following is another alternative (though it doesn't use modules):
<code>
my $debug = 0;
my $usage = "Usage: $0 [-d|-h] month start end\n blah blah";
if ( @ARGV and $ARGV[0] =~ /^-+([dh])/ ) {
shift;
die $usage if ( $1 eq 'h' );
$debug++;
}
die $usage unless ( @ARGV == 3 ); # could add more conditions...
</code><P>
<LI> Aside from using $month when naming all those output files, it's not clear what this value is important for. If it's supposed to be different from start and or end dates, how should it be different?<P>
<LI> Initializing the @greps array can be a lot simpler (and if flexibility would be useful for you, consider loading the list from a data file, which can be named on the command line):
<code>
my @greps = qw(\string\1
\string\1\extra
\string\2
%and.so.on%
);
</code><P>
</ul>
Well, enough for now. Good luck with the rest.
538316
539775