Add code to automatically uncompress .gz and .bz2 files that are given as arguments.

This commit is contained in:
dbaron@dbaron.org 2007-06-20 14:59:33 -07:00
parent f8ae555c59
commit 2ffac68147

View File

@ -127,7 +127,15 @@ sub add_file($$) {
my ($infile, $factor) = @_;
open (INFILE, "<$infile") || die "Can't open input \"$infile\"";
if ($infile =~ /\.bz2$/) {
# XXX This doesn't propagate errors from bzip2.
open (INFILE, "bzip2 -cd '$infile' |") || die "Can't open input \"$infile\"";
} elsif ($infile =~ /\.gz$/) {
# XXX This doesn't propagate errors from gzip.
open (INFILE, "gzip -cd '$infile' |") || die "Can't open input \"$infile\"";
} else {
open (INFILE, "<$infile") || die "Can't open input \"$infile\"";
}
while ( ! eof(INFILE) ) {
# read the type and address
my $line = <INFILE>;