And this is your code that I am unsure of how to search for all .bz2 files: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; }
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; }
In reply to Re^5: Grep logs by start date and end date in different directories
by Anonymous Monk
in thread Grep logs by start date and end date in different directories
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |