in reply to opening directories in perl

You can certainly brew up your own solution with opendir(); one other (possibly easier) solution would be to use module File::Find.

Replies are listed 'Best First'.
Re^2: opening directories in perl
by Anonymous Monk on Jul 03, 2005 at 19:24 UTC
    I'm having some real problems with this File::Find module!

    I have read the relevent docs but am really unsure what to but in the wanted subroutine in order to find the files I want. The files I want to get are new/something_here/mlc

    use File::Find; my $dir = ('new/'); find (\&wanted, $dir); # this bascially lists all the directories, how can I get it to look f +or my 'mlc' files? sub wanted { print $File::Find::dir; }
      In the documentation I find this snippet:
      The wanted() function does whatever verifications you
      want.  $File::Find::dir contains the current directory
      name, and $_ the current filename within that directory.
      $File::Find::name contains the complete pathname to the
      file. 
      
      So I'd try this to start (untested):
      my @mlc; sub wanted { return unless $_ eq 'mlc'; push @mlc, $File::Find::name; } find(\&wanted, '.'); foreach my $file (@mlc) { open(my $fh, $file) or die "Can't open '$file': $!"; # per-file code goes here }