Perl application – delete “. SVN” folder in current directory and subdirectory

Use the File::Find module
The File::Find module in Perl is used for searching and finding files. Can be used to search for filenames across the file system, using regex to match filenames and looping through any directory structure.
Two methods of the File::Find module
The find method traverses from top to bottom.
The findDepth method iterates from the bottom up.

Function Prototypes
 use File::Find;
 find(\&wanted, @directories_to_search);
 sub wanted { ... }

where the first argument wanted is a subfunction, a callback function, which you define yourself.
This parameter must be there, even if its content is empty. The second argument is a list of directories, which can also be
is a common string scalar for directory names. Note that the &wanted subroutine needs to be preceded by a backslash escape. 

both call in the same format, such as finddepth(\& Del_svn, “.”) , the first argument is the called subfunction, the second argument is the directory, “.”) , the first argument is the called subfunction, the second argument is the directory, “.” represents the current directory. represents the current directory.

#!/usr/bin/perl /usr/bin/perl -w
#Function: The script deletes all .svn files from the current directory and its subdirectories.
# Use: command line type: perl delete_svn.pl
# Save the following code in the file named delete_svn.pl
use strict;
use File::Find;

sub del_svn {
    if ($_ eq ".svn") {
       system("rm -rf $_");
    }
}

finddepth(\&del_svn, ".");
print "finished.\n";

The system function is used to invoke the system command, and RM-RF is used to delete the command under Linux

Read More: