Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 2, 2007, 02:02 PM   #1
Corrosive vinyl
macrumors 6502
 
Join Date: Sep 2006
how to use perl

Sorry for the total newb questions, but gotta start somewhere. I got this cool book called Programming perl and have started weeding through the 1,000 some pages of it. Where can I write and compile this stuff I am learning? Do I need to get Xcode? Also, How can I open apps so I can see the code? I basically am interested in this language and want to implement it.
__________________
"Technological progress is like an axe in the hands of a pathological criminal."
"Nationalism is an infantile disease. It is the measles of mankind. " -Einstein
Corrosive vinyl is offline   0 Reply With Quote
Old Jul 2, 2007, 02:25 PM   #2
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
Perl is not a compiled language (in the traditional sense). Just save plain text files (you can do that with Text Edit) and run them in the Terminal via perl <filename>
robbieduncan is offline   0 Reply With Quote
Old Jul 2, 2007, 03:07 PM   #3
Corrosive vinyl
Thread Starter
macrumors 6502
 
Join Date: Sep 2006
coolness... so just go to text edit and write out perl stuff like print "howdy, there!"\n then go to terminal and type perl <texteditfile> that is very doable, thanks!
__________________
"Technological progress is like an axe in the hands of a pathological criminal."
"Nationalism is an infantile disease. It is the measles of mankind. " -Einstein
Corrosive vinyl is offline   0 Reply With Quote
Old Jul 2, 2007, 03:11 PM   #4
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
Just make sure TextEdit is in plain text mode. If you have the formatting toolbar find the Format->Make Plain Text command.

If you want to be able to just type perl <file> make sure you save the file in your home directory (not Documents).

You can use the cd command to change directories in Terminal to get to wherever you save it.
robbieduncan is offline   0 Reply With Quote
Old Jul 2, 2007, 04:06 PM   #5
iSee
macrumors 68040
 
iSee's Avatar
 
Join Date: Oct 2004
You might also look at getting a text editor that does syntax highlighting for Perl. There are free ones around.

I don't want to start another "which text editor is better" battle, but I know TextWrangler is a freeware editor with basic Perl syntax highlighting. I found the highlighting very useful as I learned the language.
iSee is offline   0 Reply With Quote
Old Jul 2, 2007, 04:13 PM   #6
cube
macrumors G3
 
Join Date: May 2004
You don't need to type perl on the command line all the time

Just make the first line of the file be:
#!/usr/bin/perl

If the file is called "myscript" then you do:
chmod u+x myscript

And just run as:
myscript
cube is offline   0 Reply With Quote
Old Jul 2, 2007, 05:02 PM   #7
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
Quote:
Originally Posted by cube View Post
And just run as:
myscript
Probably actually as ./myscript unless the OP has added ./ (or the current directory explicitly) to the PATH.
robbieduncan is offline   0 Reply With Quote
Old Jul 2, 2007, 05:05 PM   #8
cube
macrumors G3
 
Join Date: May 2004
You don't add "./", you just add "."
cube is offline   0 Reply With Quote
Old Jul 2, 2007, 05:12 PM   #9
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
Quote:
Originally Posted by cube View Post
You don't add "./", you just add "."
I think you'll find I'm correct and you are wrong. I'm a professional Unix developer.

Quote:
Originally Posted by My Terminal
jay:~ robbie$ chmod u+x test
jay:~ robbie$ .test
-bash: .test: command not found
jay:~ robbie$ ./test
test
Note that with ./ it works and just . it gives the expected command not found?
robbieduncan is offline   0 Reply With Quote
Old Jul 2, 2007, 05:13 PM   #10
cube
macrumors G3
 
Join Date: May 2004
I'm talking about PATH
cube is offline   0 Reply With Quote
Old Jul 2, 2007, 05:16 PM   #11
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
Quote:
Originally Posted by cube View Post
I'm talking about PATH
In which case either will work, but as I clearly typed the whole command it was clear that I was using ./<command> to explicitly run a command in the CWD, and this was not talking about the PATH, that was a separate aside.
robbieduncan is offline   0 Reply With Quote
Old Jul 2, 2007, 05:22 PM   #12
cube
macrumors G3
 
Join Date: May 2004
You said:

Quote:
unless the OP has added ./ (or the current directory explicitly) to the PATH.
I don't say it won't work. I mean real Unixers just use "."
cube is offline   0 Reply With Quote
Old Jul 2, 2007, 06:12 PM   #13
Corrosive vinyl
Thread Starter
macrumors 6502
 
Join Date: Sep 2006
so if i put scripts in documents/myscripts folder i just cd documents/myscripts then do perl "<file>" whatever file that may be and it runs whatever I wrote...
__________________
"Technological progress is like an axe in the hands of a pathological criminal."
"Nationalism is an infantile disease. It is the measles of mankind. " -Einstein
Corrosive vinyl is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Need help: Perl scripting iAintKnowMac Mac Programming 5 Jul 2, 2013 10:28 PM
Very simple(?) question from newbie about perl/textedit sun surfer Mac Programming 8 Jun 24, 2013 04:27 PM

Forum Jump

All times are GMT -5. The time now is 05:16 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC