skip path prune

W

weberw

How do you use the prune function to skip a printing all of the
contents of a folder? It will not print folder 3 but does print the
contents of folder 3 which I do not want printed.

#!C://Perl/bin/perl
use CGI ':standard';
use CGI::Carp 'fatalsToBrowser';
#use strict;
use warnings;
use File::Find;
my $file_count = 0;
my $dir_count = 0;


$title = "Find Files";
print header,
start_html($title),
h1($title);

find ( {
wanted => \&wanted}, 'C:/Documents and
Settings/whatever/Desktop/test');

printf "\nThere are %d files in %d directories.\n",
$file_count,
$dir_count;

sub wanted {

if (-d) {

print $File::Find::name, "\n" unless -d =~ /^folder3/;

$dir_count++;
}

elsif (-f _) {
print " <TR> <TD ALIGN=RIGHT>File name is
$File::Find::name</TD></TR><BR></BR>";


$file_count++;

}
}


end_hmtl;
 
M

Mumia W.

How do you use the prune function to skip a printing all of the
contents of a folder? [...]

Prune is not a function but a variable. Inside your wanted
function, if you see a directory that you don't want to look
inside, set $File::Find::prune to '1' to skip its contents.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top