@Tom, Thanks! @Chas, I am still *very* new to Perl, so can you enlighten me as to what I did wrong with the dir handle? When you say iterative reading, I am lost. This "globbing" does look simpler...
As this turns out, it looks like I could just grep the output into an array making sure only image[n] gets in. That's close enough to what I need, as I realized the only files I need are in the format of "image" + some positive integer. But I still have to make sure they don't have extensions like .txt as some do. I will start reading over both of your points. Thanks! jlc -----Original Message----- From: Chas. Owens [mailto:[EMAIL PROTECTED] Sent: October-18-07 2:53 PM To: Joseph L. Casale Cc: beginners@perl.org Subject: Re: Filtering output of readdir 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/