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

Regarding decompressing, there is the core module IO::Uncompress::Bunzip2 that you should be able to use fairly transparently:

# untested use IO::Uncompress::Bunzip2 (); my $fh = IO::Uncompress::Bunzip2->new($filename)     or die "bunzip2 $filename: $IO::Uncompress::Bunzip2::Bunzip2Error" +; # use $fh like a regular filehandle

As for the second question, it'd be best if you followed the advice in SSCCE and How do I post a question effectively? - especially if it's urgent, since the advice on those pages will help us provide you with help efficiently. Since the above questions aren't closely related to the original one, you may also want to post a new question in a new thread. Anyway, there have been a few recent threads with similar topics that you might be able to get some information from:

  • Comment on Re^4: Grep logs by start date and end date in different directories
  • Download Code

Replies are listed 'Best First'.
Re^5: Grep logs by start date and end date in different directories
by Anonymous Monk on Jan 08, 2018 at 01:43 UTC
    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 }
      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.