Hi Sumit,

I have 3 options for you.

First One : using the *rmtree* subroutine from *File::Path* Module


*rmtree('foo/bar/baz', 1, 1);*

, the rmtree function provides a convenient way to delete a subtree from the
directory structure, much like the Unix command rm -r. rmtree takes three
arguments:

   - the root of the subtree to delete, or a reference to a list of
   roots. All of the files and directories below each root, as well as the
   roots themselves, will be deleted.
   - a boolean value, which if TRUE will cause rmtree to print a message
   each time it examines a file, giving the name of the file, and indicating
   whether it's using rmdir or unlink to remove it, or that it's skipping
   it. (defaults to FALSE)
   - a boolean value, which if TRUE will cause rmtree to skip any files
   to which you do not have delete access (if running under VMS) or write
   access (if running under another OS). This will change in the future when a
   criterion for 'delete permission' under OSs other than VMS is settled.
   (defaults to FALSE)

It returns the number of files successfully deleted. Symlinks are simply
deleted and not followed.
-----------------------------------------------------------------------------------------------------------------------

Second option is writing your own recursive sub routine to remove the
directory tree

sub cleanup {
        my $dir = shift;
local *DIR;

opendir DIR, $dir or die "opendir $dir: $!";
my $found = 0;
while ($_ = readdir DIR) {
        next if /^\.{1,2}$/;
        my $path = "$dir/$_";
unlink $path if -f $path;
cleanup($path) if -d $path;
}
closedir DIR;
rmdir $dir or print "error - $!";
}

---------------------------------------------------------------------------------------------------------

The third one is a very simple one and which i prefer as i am very lazy :)

simply use the system function with the unix command

*system(rm -rf <<path>> );*
**
**


-- 
~Regards
Srinivas




=====================================================
      Mark your calendar for the next TSM
      Saturday (5pm - 7:30pm) on 28th October 2006

      DSPACE

      DSPACE is an open source software package which provides 
      the tools for management of digital assets, and is commonly 
      used as the basis for an institutional repository. 

      It is also intended as a platform for Digital preservation
      activities. Since its release in 2002, as a product of the 
      HP-MIT Alliance, it has been installed and is in production 
      at over 100 institutions around the globe, from large 
      universities to small higher education colleges and 
      research centres. 
      

      Venue:
      5th Floor, Conference Room
      COMMVAULT Systems (India) Pvt Ltd.

      Ashoka Janardhan Chambers
      S. P. Road, Begumpet
      Hyderabad.

      Helpline:
      +91 - 98482 37656 

      To know more about TWINCLING Society
      http://www.twincling.org/

      Visit the TWINCLING Photo Gallery at
      http://www.flickr.com/photos/twincling
=====================================================
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/twincling/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/twincling/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to