CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Frequently Asked Questions:
How Do I delete A File?

 



sleuth
Enthusiast

Dec 12, 2000, 2:50 PM

Post #1 of 1 (4395 views)
How Do I delete A File? Can't Post

use unlink.

unlink "file.txt";

If the file is located in another directory than the one your script is executing from, then simply specify the full path before the file's name.

unlink "/path/to/file.txt";

To check and see if this code fails, use this

unlink "file.txt" or die "Couldn't Delete File because: $!";

Instead of die you can use print to actually print the message to the screen, when you execute your code through a browser this will help more than die, but the script will continue executing.

Sleuth


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives