in reply to Re: thanks
in thread thanks, i'm new. rtfm right? :)

You can parse the files in the directory with a structure like this, instead of using opendir/readdir/closedir:
my @files = (); foreach (<*$count*>) { s/\.[^.]*$//; push @files, $_; }

Not sure what you needed to do with the files, but you might do that inside the loop as well. I'm not sure exactly how <*> works internally, but it's definitly better than doing a system() call that relies on ls, awk, and grep (even if those are fine tools). I find it cool, yet strangely disturbing, that you can interpolate the variable $count into the <...> directory listing.

-Ted

Replies are listed 'Best First'.
RE: Don't use opendir
by runrig (Abbot) on Oct 25, 2000 at 21:56 UTC
    <*> (file globbing) used to spawn a csh process (and used to do some other horrible thing on Windows), but now (as of 5.6?) uses File::Glob. I still avoid it, because (open|read|close)dir with grep provides better file and pattern matching capabilities. And maybe I just find the syntax ambiguous (I confuse it with reading lines of a filehandle), which is maybe just my own prejudice. I'm curious as to what others think of file globbing vs. readdir...
      Absolutely. I was seriously burned once on an older Perl with scripts that used globbing which began returning nothing when the directory got too many files. *THAT* was a fun one to debug, and I am not a great fan of rewriting production jobs on the fly. :-(

      Even with File::Glob I would avoid globbing if there was going to be any possibilities of filenames with spaces or wildcards in them. The semantics of readdir etc are safe with meta-characters. The sematics of globbing are very troublesome.