For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > January 2006 > Re: 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 Re: checking gzip files
Tom Phoenix

2006-01-10, 4:02 am

On 12/30/05, S Khadar <ibiokid@gmail.com> wrote:
> $dir =3D shift;
> $dir =3D"/home/trial";


You seem to be over-writing what you just put into $dir. (I think this
is just your debugging code, though.)

> opendir(M,"$dir");


Just as when using open(), it's important to check for errors with
opendir() by using "or die". The double quote marks around the
variable name are superfluous.

opendir(M, $dir) or die "Can't opendir '$dir': $!";

> $dmchk=3Dzless( "$dir/$_/foo.gz");
>
> if (-z "$dmchk")


That test is looking to see whether the file named by $dmchk is a
zero-byte file. (Again, the double quote marks are superfluous around
a simple scalar name.) So, if that variable contains "fred", and
there's an empty file named fred in the current directory, it returns
true. That's probably not what you meant to do. (Did you want to use
regular expressions to examine the content of $dmchk?)

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training
Sponsored Links







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

Copyright 2009 codecomments.com