On 10/18/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: > Hi All, > > I am needing to perform some work on files located in a directory. I am > reading > the contents of the directory in and but need to filter what's read in. So > far I > can filter out the "." and ".." but I need to add two more cases. I need to > make > sure none of the entries in the array are directories or files with > extensions. snip > my @files = grep { $_ ne '.' && $_ ne '..' } readdir(DIR); snip
regexes and file test operators are your friends. Also, don't use dirhandles if you are just going to use readdir in list context. dirhandles are for iterative reading. Use a glob to get a list: my @files = grep { not (/\./ or -d) } <$InDir/*>; @files will contain all files that are not directories (not -d) and do not contain a period (that is the only way to test for "extensions" since the concept of extensions is not part of the file system, but is rather a convention of naming). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/