skip path prune

Discussion in 'Perl Misc' started by weberw@adelphia.net, Jul 17, 2006.

  1. Guest

    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;
    , Jul 17, 2006
    #1
    1. Advertising

  2. Mumia W. Guest

    On 07/17/2006 11:34 AM, 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::prune to '1' to skip its contents.
    Mumia W., Jul 17, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rory Campbell-Lange

    newbie : prune os.walk

    Rory Campbell-Lange, Mar 10, 2005, in forum: Python
    Replies:
    4
    Views:
    476
    Tim Roberts
    Mar 12, 2005
  2. Girish Sahani
    Replies:
    3
    Views:
    272
    Bruno Desthuilliers
    Jun 29, 2006
  3. Martin Elzen
    Replies:
    2
    Views:
    126
    Ken Bloom
    Apr 25, 2008
  4. afrinspray

    MIME::Parser and Purge / Prune

    afrinspray, May 31, 2006, in forum: Perl Misc
    Replies:
    1
    Views:
    112
    afrinspray
    Jun 9, 2006
  5. skip path prune

    , Jul 17, 2006, in forum: Perl Misc
    Replies:
    0
    Views:
    63
Loading...

Share This Page