# # $Id: openlogfile.pl,v 1.3 2001/07/17 02:26:22 root Exp $ sub open_log_file { # open log files whether they're compressed or not my $zcat = "/bin/zcat" ; my $gzcat = "/bin/zcat" ; my $bzcat = "/usr/bin/bzcat" ; my ($file) = shift ; if ($file eq "-") { open(FILE, "<&=STDIN"); } else { my $mm = new File::MMagic; my $res = $mm->checktype_filename($file); #print "$file: $res\n" ; if ($res eq "application/x-compress") { open(FILE,"$zcat $file|") || die "couldn't run '$zcat $file': $!" ; } elsif ($res eq "application/x-gzip") { open(FILE,"$gzcat $file|") || die "couldn't run '$gzcat $file': $!" ; } elsif ($res eq "application/x-bzip2") { open(FILE,"$bzcat $file|") || die "couldn't run '$bzcat $file': $!" ; } else { open(FILE,$file) || die "couldn't open $file: $!" ; } ; } ; return *FILE ; } ; return 1;