Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > skip path prune

Reply
Thread Tools

skip path prune

 
 
weberw@adelphia.net
Guest
Posts: n/a
 
      07-17-2006
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;

 
Reply With Quote
 
 
 
 
Mumia W.
Guest
Posts: n/a
 
      07-17-2006
On 07/17/2006 11:34 AM, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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:rune to '1' to skip its contents.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update: how to prune newsrc thanatoid Computer Support 10 01-25-2009 03:08 AM
Find.prune if ( filename[-5,5] != ".java") is odd? Martin Elzen Ruby 2 04-25-2008 03:15 PM
skip path prune weberw@adelphia.net Perl Misc 0 07-17-2006 04:34 PM
Function to prune dictionary keys not working Girish Sahani Python 3 06-29-2006 12:33 AM
newbie : prune os.walk Rory Campbell-Lange Python 4 03-12-2005 06:44 AM



Advertisments