Unable to remove files from directory

linux, perl

Solution

Perl has a builtin function for removing files, `unlink`. The third example shows how to use it in combination with `glob` to delete a list of files:

unlink glob "*.bak";

or in your case,

unlink glob($directory.$files);

Problem

I am using rm to delete some files from a directory through a Perl script but it throws the error `can't exec "rm" no such file or directory`. Command goes like this : ``` system("rm $directory$files"); $directory$files = /var/spool/mqueue/qf* ```

Original source