Which operating system? Operating systems have different security systems and ways to set them. For example on UNIX it is fairly easy to use
from Perl since it is a built-in, but on Windows you might have to use the Win32 API, which is quite complex.
. It might not be the most efficient way of doing it, but will probably be the simplest.