There is a similar question about Windows, but it won't work for Unix based computers (OS X specifically).
I want to type the name of a file, say example.pl or example.pl parametertext.txt, and have it know to execute perl.
I specified #!/usr/bin/perl in the file so it can find the executable.  Instead, I get the message:
bash: example.pl: command not found
                at the top of your perl script, mark the script as executable with the UNIX chmod command, and execute the perl program by simply typing its name at a UNIX prompt.
You can do it this way,
/usr/bin/perl or /usr/bin/env perl
#!/usr/bin/perl.chmod +x example.pl
Now it will run
    $ ./example.pl
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With