in reply to Encrypt perl script

I would not do this within Perl. I would use the OS to accomplish this task. You mentioned terminals, so that might imply a Unix flavor or variant. I would use a special user id and sudo to accomplish this task in Unix.

NOTE: I intend to meet your requirements of being able to run a command, but not being able to view the command. I do not intend to encrypt anything. Encryption in this case seems to be an XY problem.

Here is the example command. The file is owned by our special user sexec. The group owner is root. The other permissions are all turned off.

root@mybox:/tmp/fakebin # ls -ld . drwxr-xr-x 2 root root 1024 Jan 28 09:44 . root@mybox:/tmp/fakebin # ls -l total 1 -rwxr-x--- 1 sexec root 90 Jan 28 09:44 cmd.pl root@mybox:/tmp/fakebin # cat cmd.pl #!/usr/bin/perl -w use strict; use warnings; print "Secret command output.\n"; exit 0;

Here is the /etc/sudoers line that lets user bob run cmd.pl as user sexec.

bob ALL = (sexec) NOPASSWD: /tmp/fakebin/cmd.pl

Here is the end result actions. User bob can run the command, but he can't view it.

bob@mybox:~ $ sudo -u sexec /tmp/fakebin/cmd.pl Secret command output. bob@mybox:~ $ cat /tmp/fakebin/cmd.pl cat: /tmp/fakebin/cmd.pl: Permission denied bob@mybox:~ $ sudo -u sexec /bin/cat /tmp/fakebin/cmd.pl Password: Sorry, user bob is not allowed to execute '/bin/cat /tmp/fakebin/cmd.p +l' as sexec on mybox.localdomain.tld.