For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > January 2006 > Fwd: checking gzip files









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Fwd: checking gzip files
S Khadar

2006-01-10, 4:02 am

Hi all,

I have a 15 thousand directories - each of them contain say 10 files (all
*.gzip)
out of this 10 *.gz files - I want to check whether a file named foo.gz
contain any content or not - since my files are gzipped even the blank file
occupies some size.

have a look at my code
-----------------------------------------
#!/usr/bin/perl
use Shell;

$dir = shift;
$dir ="/home/trial";
opendir(M,"$dir");
@a = readdir(M);
close M;

open(KL,">Dumo-chk");
print KL " << List of foo.gz with no contents >> \n";

foreach (@a)
{
print"\n\t\tProcessing $_\n";
print"\tUncompressing and Readingfoo.gz\n";
next if ($_ =~ /^\./);
# my code works fine untill here ---
------------------------------------ here i have the problem
$dmchk=zless( "$dir/$_/foo.gz");

if (-z "$dmchk")
{
print KL "\n$_ No - content\n";
}
else
{
print KL "$_ -foo-content\n";
}
}


- I am sure there is more than one day to do it
- thanks in advance
Happy PERL
iBioKid - S K

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com