[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] Log files might be bz2'd hack




On Jun 9, 2005, at 11:29 AM, Andy Lester wrote:
On Thu, Jun 09, 2005 at 11:23:03AM -0500, Jay Hannah (jhannah@omnihotels.com) wrote:
my $glob = "/junk/__peglogs/comserver-trans-a.log.$y$m$d";
my $cat = "cat";
if (`ls $glob*.bz2 2>/dev/null`) {
   $cat = "bzcat";
}

You don't need to use `ls` to get a list of files.

my @files = glob( "$glob*.bz2" );

oooooo!! Slick!

So I guess I could have done something like....

my $glob = "/junk/__peglogs/comserver-trans-a.log.$y$m$d";
my $cat = "cat";
if (glob("$glob*.bz2")) {
   $cat = "bzcat";
}
open (IN, "$cat $glob* |");
while (<IN>) {
   .....

or better yet (?):

my $glob = "/junk/__peglogs/comserver-trans-a.log.$y$m$d";
my $cat = glob("$glob*.bz2") ? "bzcat" : "cat";
open (IN, "$cat $glob* |");
while (<IN>) {
   .....

j