| 1 |
|
|---|
| 2 |
|
|---|
| 3 | print "\nModifying the '.t' files...\n\n";
|
|---|
| 4 |
|
|---|
| 5 | use File::Basename;
|
|---|
| 6 | use File::Copy;
|
|---|
| 7 |
|
|---|
| 8 | ## Change the below line to the folder you want to process
|
|---|
| 9 | $DirName = "/perl/scripts/t";
|
|---|
| 10 |
|
|---|
| 11 | $FilesTotal = 0;
|
|---|
| 12 | $FilesRead = 0;
|
|---|
| 13 | $FilesModified = 0;
|
|---|
| 14 |
|
|---|
| 15 | opendir(DIR, $DirName);
|
|---|
| 16 | @Dirs = readdir(DIR);
|
|---|
| 17 |
|
|---|
| 18 | foreach $DirItem(@Dirs)
|
|---|
| 19 | {
|
|---|
| 20 | $DirItem = $DirName."/".$DirItem;
|
|---|
| 21 | push @DirNames, $DirItem; # All items under $DirName folder is copied into an array.
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | foreach $FileName(@DirNames)
|
|---|
| 25 | {
|
|---|
| 26 | if(-d $FileName)
|
|---|
| 27 | { # If an item is a folder, then open it further.
|
|---|
| 28 |
|
|---|
| 29 | opendir(SUBDIR, $FileName);
|
|---|
| 30 | @SubDirs = readdir(SUBDIR);
|
|---|
| 31 | close(SUBDIR);
|
|---|
| 32 |
|
|---|
| 33 | foreach $SubFileName(@SubDirs)
|
|---|
| 34 | {
|
|---|
| 35 | if(-f $SubFileName)
|
|---|
| 36 | {
|
|---|
| 37 | &Process_File($SubFileName); # If file, process it.
|
|---|
| 38 | }
|
|---|
| 39 | else
|
|---|
| 40 | {
|
|---|
| 41 | $SubFileName = $FileName."/".$SubFileName;
|
|---|
| 42 | push @DirNames, $SubFileName; # If sub-folder, push it into the array.
|
|---|
| 43 | }
|
|---|
| 44 | }
|
|---|
| 45 | }
|
|---|
| 46 | else
|
|---|
| 47 | {
|
|---|
| 48 | if(-f $FileName)
|
|---|
| 49 | {
|
|---|
| 50 | &Process_File($FileName); # If file, process it.
|
|---|
| 51 | }
|
|---|
| 52 | }
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | close(DIR);
|
|---|
| 56 |
|
|---|
| 57 | print "\n\n\nTotal number of files present = $FilesTotal\n";
|
|---|
|
|---|