It is fairly easy, you run it in the directory you want to recursively change permissions on.
For example:
perl perms.pl 750 640 zefie zefieWould set all files under my home directory to 640 (rw/r/-), and all directories to 750 (rwx/rx/-), and make the owner and group "zefie".