jeudi 3 décembre 2015

in perl: Why use the -s file test on a directory?

I'm starting to try to understand Higher Order Perl. In his directory-walker program he has a sub called dir_size (at the top of page 22).

In that sub he has a statement:

my $total = -s $dir; 

where he already knows that $dir is the name of a directory.

$total is apparently Always set to 0, regardless of the actual size of the directory (which doesn't contradict anything the documentation says).

Is there any reason he doesn't simply say $total=0; and avoid the overhead of a system call?

Aucun commentaire:

Enregistrer un commentaire