Skip to content

Instantly share code, notes, and snippets.

@viliampucik
Created March 21, 2013 12:39
Show Gist options
  • Save viliampucik/5212724 to your computer and use it in GitHub Desktop.
Save viliampucik/5212724 to your computer and use it in GitHub Desktop.
Perl's zgrep
#!/usr/bin/env perl
use strict;
use warnings;
use PerlIO::gzip;
my $pattern = $ARGV[0];
my $file = $ARGV[1];
open my $z, '<:gzip', $file or die "gunzip failed: $!\n";
while ( <$z> ) {
print if /$pattern/i;
}
close $z;
@khamil8686
Copy link

Thank you. I was looking for a basic, "How do I quickly open this damn gz file in Perl without too much hassle and googling?" This was it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment