How do I run a Perl script on OS X?
I honestly can't find the answer anywhere! Presumably I have to run a command in Terminal but what?
(I know this is a real basic and stupid question)
Mac OS X already has Perl installed. Open a Terminal application (in the Utilities folder of your Applications folder) and run perl -v to find out which version. ActiveState Perl has binary distributions of Perl for Mac OS X. This is the simplest way to install the latest version of Perl.
The path to Perl on Mac is /usr/bin/perl.
You can run your Perl
script by invoking the Perl
interpreter and giving your file as input:
perl myprogram.pl
The easiest way to run a perl script is with the option:
perl myprogram.pl
However, you may find it more useful to add a shebang line at the top of the perl file.
#!/usr/bin/perl print "Hello World!\n";
In order to execute this script, you need to add execute permissions to your program. Run:
chmod +x myprogram.pl
Now, in order to run your script, you can simply type:
./myprogram.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