Loading ...
Sorry, an error occurred while loading the content.

Building an array of selected dir entries

Expand Messages
  • cajun@cajuninc.com
    I m having trouble coming up with a way to do this. I have a directory with multiple files and subdirectories in it. I am only interested in files that have
    Message 1 of 1 , Jan 31, 2001
    • 0 Attachment
      I'm having trouble coming up with a way to do this. I have a directory
      with multiple files and subdirectories in it. I am only interested in
      files that have names like:
      01file_
      02file_
      03file_
      etc

      In other words, only files ending in underscore character with no extension.

      Here's what I've done thus far, but it seems there should be a better way:

      opendir DIR, $path;
      my @files = readdir DIR;
      for $i (@files){
      next if $i=~/^\./; # skip the . and the .. files
      next if $i=~ /_$/; # skip files not ending in _
      print "$i\n";
      }

      --

      Linux: Because Bill Gates can't keep it up this long
      10:12am up 2 days, 19:07, 7 users, load average: 1.05, 1.12, 1.15
    Your message has been successfully submitted and would be delivered to recipients shortly.