Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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
Replies are listed 'Best First'.
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, <*>;
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.

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 chilling in the Monastery: (11)
As of 2015-07-29 09:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls