in reply to Re^4: Grep logs by start date and end date in different directories
in thread Grep logs by start date and end date in different directories

Update, I managed to get the IP address subnet range searching to work. However, to implement it into your code, I am unsure why when i put ->name('*.bz2') it doesn't work.. This is my code currently:
use strict; use warnings; use IO::Uncompress::Bunzip2 (); use Net::Subnet; my $filename = "debug.log.bz2"; my $fh = IO::Uncompress::Bunzip2->new($filename) or die "bunzip2 $filename: $IO::Uncompress::Bunzip2::Bunzip2Error" +; my $matcher = subnet_matcher qw(72.46.130.0/24); while (<$fh>){ my @ips = m/(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25 +[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/g; next unless @ips; next unless grep { $matcher->($_) } @ips; print; }
And this is your code that I am unsure of how to search for all .bz2 files:
sub get_files { my (@dirs) = @_; my $level = shift // 3; # level to dig into my @files = File::Find::Rule->file() ->name('*.bz2') #this line doesn't work ->maxdepth($level) ->in(@dirs); return @files; }