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

Hi haukex, thank you so much for your reply. Managed to get it to work. However what happens if I want to read multiple bz2 files instead of 1 bz2 file? My current code is:
my $filename = "debug.log.bz2"; my $fh = IO::Uncompress::Bunzip2->new($filename) or die "bunzip2 $filename: $IO::Uncompress::Bunzip2::Bunzip2Error" +; while(<$fh>){ #do something }
  • Comment on Re^5: Grep logs by start date and end date in different directories
  • Download Code

Replies are listed 'Best First'.
Re^6: Grep logs by start date and end date in different directories (updated)
by haukex (Archbishop) on Jan 09, 2018 at 21:58 UTC
    However what happens if I want to read multiple bz2 files instead of 1 bz2 file?

    You should just be able to put the code you showed in a loop, for example my @files = ("debug.log.bz2", "debug2.log.bz2", ...); for my $filename (@files) { my $fh = ... }.

    Update: If you're the same anonymous poster, then you seem to have already figured that out here. You might want to consider registering an account so that your threads can be more easily connected, and so that you can edit your posts instead of making multiple anonymous "update" posts. Even if you already have an account you can still register a second one for use at work as long as you observe the Site Rules Governing User Accounts.