"Uri Guttman" <u...@stemsystems.com> writes:

>>>>>> "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.

No, not windows.  Gentoo linux... 

Notice the elided marks showing that more code lies between...  the
uppercase `I' was just a typo. I cut an pasted the function, but
just typed in the `use' things as an after thought since someone here
was sure to feel the need to tell me I needed use strict, use
warning.... hehe.

In the actual script it is correctly spelled.

> 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
>       }

Thanks, that's nice to know about.  It would save a little work there.

However, apparently I don't have it installed; may get to that later.

  perldoc File::Slurp          
  No documentation found for "File::Slurp".


-- 
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