Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2009
    Posts
    1,998
    Rep Power
    1225
    Here's your complete script.
    Code:
    #!/usr/bin/perl
    
    use strict;
    use warnings;
    use File::Find::Rule;
    use File::Path qw(remove_tree);
    
    my $top = '.';
    my $name = shift || 'abc';
    
    my @paths = File::Find::Rule->name($name)->directory->in($top);
    remove_tree(@paths, {verbose => 1});
    
    # those 2 lines could be combined
    # remove_tree(File::Find::Rule->name($name)->directory->in($top), {verbose => 1});
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Location
    Paris area, France
    Posts
    844
    Rep Power
    496
    Originally Posted by bonny1989
    Hi All,

    Can you please help me in below give regex?
    Actually I am not good at regex.
    here, @files has the list of all the directories and files.
    and $cur_file performs the shifting operation from @files.
    ___________________________________________________
    @files = grep {$_ !~ /^[.]{1,2}$/} @files;
    @files = map {"$cur_file/$_"} @files;


    Can you tell me what actually performs?
    Let's see.

    Perl Code:
    @files = grep {$_ !~ /^[.]{1,2}$/} @files;


    This takes the original @files array and create a new version of it in which the Unix directory entries "." and ".." have been removed.

    Perl Code:
    @files = map {"$cur_file/$_"} @files;


    This takes the @files array and create a new version of it in which the bare filenames are replaced by a concatenation of the content of the $cur_file variable (presumably a directory), the "/" character and the original bare name. For example, if $cur_file contains "/home/User", and if @files contains foo.txt and bar.txt, the new array now contains /home/User/foo.txt and /home/User/bar.txt.
  4. #18
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    31
    Rep Power
    2
    @FishMonger

    Thank you so much for your help.
    But actually I wanted to try without help of File::Find::Rule.
    Still thanks a lot.

    @Laurent_R

    Thank you very much.
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo