★ wanayoo — archive 1999 http://www.wdvl.com/Authoring/Scripting/Tutorial/perl_misc_file.htmlNouvelle recherche | Portail wanayoo

Play the Market--win real cash! logo

internet.com
Join the free
WDVL newsletter!

home

Deleting, Renaming and Changing the Permissions of Files

Deleting, Renaming and Changing the Permissions of Files

  • Perl also provides you with all of the file management functions typically offered by your operating system. In my experience, the three most utilized functions in CGI scripts are unlink, rename and chmod. unlink is Perl's function for deleting a file from the file system. The syntax is pretty straight forward.

    unlink ("[filename]"); 
    

  • This line of Perl code will delete the file called filename provided that the script has permissions to delete the file.

  • Your Perl script can also rename a file using the rename function:

    rename ("[old_filename]", "[new_filename]"); 
    

  • In this case, the file's name will be replaced with the new filename specified.

  • Finally, Perl gives you the ability to affect the permissions of files in the file system using the chmod function. The syntax is also fairly straight forward as follows:

    chmod (0666, "filename"); 
    

  • In this case, "filename" will be made readable and writable by user, group and world.

Additional Resources:

Writing and Appending to Files
Table of Contents
File Tests

Up to => Home / Authoring / Scripting / Tutorial

Instantly look up a "techie" word using Webopedia!!


internet.com
e-commerce
WebDeveloper Network



Copyright 1999 internet.com Corporation. Legal Notices. Privacy Policy.

www.internet.com