in reply to Deleting or unlinking a file

You seem to have forgotten the following after the shebang line:

use strict; use warnings;

See Use strict and warnings and Use strict warnings and diagnostics or die.

"However am using the below code to delete a file,change the permissions and then delete the file,for some reason the file still exists,any idea?

This doesn't make sense, you think you're deleting a file, changing permissions (of what?) then deleting the same file?

Replies are listed 'Best First'.
Re^2: Deleting or unlinking a file
by Anonymous Monk on Mar 15, 2011 at 01:44 UTC

    I cannot delete it because the file is read-only mode,hence changing the perms

      Note that on Unix (which I suppose applies, because you tried chmod 777) a file doesn't have to be writable to be deletable.  The directory the file is in, however, must be writable.  This is because the directory index needs to be modified to remove the file name (=link).

      $ touch foo $ chmod 400 foo $ ls -l foo -r-------- 1 er er 0 2011-03-15 03:05 foo $ unlink foo $ ls -l foo ls: cannot access foo: No such file or directory

      So, as for your problem, is the directory writable?