Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Stat and file size

by Kenosis (Priest)
on Jul 28, 2012 at 19:46 UTC ( #984228=note: print w/ replies, xml ) Need Help??


in reply to Stat and file size

Perhaps the following -size File Test Operator and grep on a glob will work for you:

my @nonZeroSizeFiles = grep -s, <*>;

And in case you'd like to find zero-size files

my @zeroSizeFiles = grep !-s, <*>;

Hope this helps!


Comment on Re: Stat and file size
Select or Download Code
Re^2: Stat and file size
by Ormus (Initiate) on Jul 28, 2012 at 20:01 UTC
    Not sure how I would use that Kenosis, sorry

      Here's one way to use it:

      use strict; use warnings; my $dir = './'; my @nonZeroLengthFiles = grep -s, <$dir*>; print "$_\n" for @nonZeroLengthFiles;

      This will print a list of all zero-length files in $dir.

Re^2: Stat and file size
by jwkrahn (Monsignor) on Jul 29, 2012 at 06:45 UTC

    And in case you'd like to find zero-size files

    my @zeroSizeFiles = grep !-s, <*>;
    my @zeroSizeFiles = grep -z, <*>;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://984228]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (12)
As of 2014-10-22 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (117 votes), past polls