perl unlink question

Hi,

I have a two lines of code both intend to perform the same task.

                 unlink $CtrFile;
                 system ("rm $CtrFile");

Both of which try to delete a certain file. However when I use the unlink command the file does not get deleted. When I use the "rm" system command, the file gets deleted. Any ideas as to why the "rm" would behave differently than the unlink command?

Thanks
jerardfjay :slight_smile:

The system command parses the parameters, stripping whitespace and such; unlink just uses what you give it directly. Maybye you've got some sort of garbage in the filename.

The best way is to see the error message if any.

If you can reproduce the situation, try

unlink "file" or die $!;

and watch for the error message output. That should give you some idea.