Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Remove Directory

by Anonymous Monk
on Jul 20, 2005 at 06:05 UTC ( [id://476376]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Great Monks

I am not able to remove the directory.

But I can able to remove the file by using unlink unlink ("d:\source\temp.txt");

Please guide me

Replies are listed 'Best First'.
Re: Remove Directory
by gopalr (Priest) on Jul 20, 2005 at 06:17 UTC
      and File::Remove uses File::Path internally :)
      use File::Path; rmtree(['foo/bar/baz', 'blurfl/quux'], 1, 1);
      "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.
Re: Remove Directory
by NetWallah (Canon) on Jul 20, 2005 at 06:11 UTC
    Please RTFM.

    From the documentation of unlink:

    unlink will not delete directories unless you are superuser and the -U flag is supplied to Perl. Even if these conditions are met, be warned that unlinking a directory can inflict damage on your filesystem. Use rmdir instead.

         "Income tax returns are the most imaginative fiction being written today." -- Herman Wouk

      ... and just continuing along the RTFM line:
      rmdir FILENAME rmdir Deletes the directory specified by FILENAME if that directory is empty. If it succeeds it returns true, otherwise it returns false and sets $! (errno). If FILENAME is omitted, uses $_.

      Flavio
      perl -ple'$_=reverse' <<<ti.xittelop@oivalf

      Don't fool yourself.
Re: Remove Directory
by Samy_rio (Vicar) on Jul 20, 2005 at 06:27 UTC

    Hi, File::Remove is use to remove the directory eventhough if the directory contains files.

    use File::Remove qw(remove); remove \1, ("c:\\test\\0521823730\\");

    I think, it helps you.

    Regards,
    Velusamy R.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://476376]
Approved by jbrugger
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-18 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found