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. Advertisements

  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. Advertisements

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. poi

    Skip HttpModule Use?

    poi, Oct 29, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    533
    John Saunders
    Oct 29, 2003
  2. anand

    Skip HTML Tags while searching

    anand, Jun 7, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    548
    Oleg Tkachenko [MVP]
    Jun 8, 2004
  3. Joe Au

    how to skip validation control

    Joe Au, Aug 6, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    3,979
    Craig Deelsnyder
    Aug 6, 2004
  4. Rory Campbell-Lange

    newbie : prune os.walk

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

    MIME::Parser and Purge / Prune

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

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