Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

xCode and Perl

How do I create an xCode program that will actually compile and RUN Perl code? Or do I just have to use to terminal? that will not run basic Perl things like:

print "Hello, world!\n";


Powerbook g4 Mac OS X (10.4.6)

Posted on May 30, 2006 5:39 PM

Reply
3 replies

May 30, 2006 6:02 PM in response to Eric Obeldobel

Depending on how in depth and long the program is, I think you are making it too hard for yourself. I would consider what you want to do more akin to what I call shell scripting.

Create a document with the following (make sure you use Unix line endings):

#!/usr/bin/perl
print "Hello, world!\n"


Make the file executable using 'chmod +x' in the Terminal. Now you can just drop the file on a Terminal window to get it's full path. Just hit Return and the script will execute.

Alternatively, you can add the file extension ".command" to the file. Again, make sure it is executable. Now you can just double click the file to run it.

Matt


Mac Mini; B&W G3/300

May 30, 2006 7:11 PM in response to Eric Obeldobel

do you have the chmod +x inside of the perl program
or do you type that inside of the terminal? like
let's say my program is called hello.pl would the
terminal look like this
"$ chmod +x perl Users/Eric/Desktop/hello.pl"



To set the executable bit for the file the command would be:

$chmod +x /Users/Eric/Desktop/hello.pl



You can then run the file from the Terminal:

$/Users/Eric/Desktop/hello.pl



Alternatively, you could actually run the file without setting the executable bit by invoking the interpreter in the Terminal:

$perl /Users/Eric/Desktop/hello.pl



If you specify the interpreter on the command line, then you really don't need the first line of the script:

#!/usr/bin/perl



Matt

Mac Mini; B&W G3/300

xCode and Perl

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.