>>>>> "HP" == Harry Putnam <rea...@newsguy.com> writes:

  HP> But all I'm asking here is for the easiest way to see if the receiving
  HP> directory is empty.

  HP> The code I've devised seems pretty clunky (I haven't tested the script
  HP> yet since I'm writing several other parts right now, so not even sure
  HP> it works).  

  HP> I suspected that `find' would find at least (.) and possibly (..) like
  HP> long `ls -l' does... what I saw is that it finds only (.) if the dir
  HP> is empty.

way overkill.

  HP> So I was asking how to do that test in case there is a better way.
  HP> -------        ---------       ---=---       ---------      -------- 
  HP>   [...]
  
  HP>   use strict;
  HP>   use warnings;
  HP>   use FIle::Find;
  
spelling. case matters at least on unix when loading a file. this means
you are on winblows where it doesn't matter. but it will matter even
then when you import stuff as the package name will not be the same.

use File::Slurp::read_dir. it will return a list of files in a dir and
it filters out . and .. for you. so a test for an empty dir is simple:

        if ( my @files = read_dir( $dir ) ) {

                # process @files
                # remember to prefix $dir/ to the file names
        }
        else {
                # empty dir
        }

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to