Make your own free website on Tripod.com

The source for the rmalldir Perl Script



  #!/usr/bin/perl -w

  use strict;

  #Open file (dirlist) for the names of the dirs to delete, then delete them
    open DIRS, "< ./dirlist " or die "Can't open dirlist: $!";
    my @dir_array = <DIRS>;
    close(DIRS);
    unlink "./dirlist" or warn "Couldn't delete dirlist: $!";

  #Use system command to remove directory, only deletes dirs in "./dirlist"
    foreach (@dir_array){
        system "rm -rf $_";
    }

  #Prints which directories were deleted
    print "Removed the following dirs:\n @dir_array\n";