[ale] Perl Problem

Terry Lee Tucker terry at esc1.com
Tue Oct 13 16:17:24 EDT 1998


Hi ALE:

The script below is a portion of a larger script. I'm having a problem
with the prune variable. I only want File::Find to look in the directory
I pass as an argument for files that match the pattern defined in the
"wanted" subroutine. According to my "Programming Perl" book by
O'Reilly, I should set the variable $File::Find::prune to true to
prevent find descending into subdirectories. When I set this variable, I
get nothing at all back. I know there are files that match this pattern
in the directory I am passing to find, but I get nothing back. If I set
the variable to zero, I get files from the /esc/rnd/prog directory, as
well as all the subdirectories below, which is not what I want. Am I
doing something wrong here?

Any insight greatly appreciated :^>

#!/usr/bin/perl

use File::Find;

sub wanted()
{
    $File::Find::prune = 1;                 # don't descend subdirectors
    (/^.*\.p$/) && push @files, $File::Find::name;
}

find (\&wanted, "/$MNT/$DIR/prog/");
foreach $value (@files)
{
    print "$value\n";
}

-- 
Oakwood, GA 30566 USA
770.965.9294
http://www.esc1.com
The Gates of hell shall NOT prevail...






More information about the Ale mailing list