Ronen Kfir wrote:
> 
> Hi,

Hello,

> I want to use readdir to read a directory tree & find a certain file,
                                  ^^^^^^^^^^^^^^
If you need to read a directory tree then you need to use the File::Find
module.


> which might be present in many subdirectories (this file will be a
> trigger to continue of the process). Then I want to define a few
> variables respectively to the number of files found in readir that
> will define the path of those files.  Then conditioned to each path
> the readdir found, pick up some other file from that directory &
> attach it to a mail message.
> 
> The part of the attachment to a mail message I have. What I miss is
> all the rest I have described.

Something like this should work (untested):

use File::Find;

my $search_dir = '/some/dir';
my $file       = 'certain file';
my $other_file = 'other file';
my @found_dirs;

find( sub { $_ eq $file and push @found_dirs, $File::Find::dir },
$search_dir );

for my $dir ( @found_dirs ) {
    if ( open my $fh, "$dir/$other_file" ) {
        my $data = do { local $/; <$fh> };
        # do something with the data from other_file
        }
    }

__END__


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to