Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 2, 2007, 01: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, 01: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, 02: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, 02: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, 03:06 PM   #5
iSee
macrumors 68030
 
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, 03: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, 04: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, 04: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, 04: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, 04: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, 04: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, 04: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, 05: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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
How to convince my parents to let me buy a 17" MacBook Pro Ulf1103 Buying Tips and Advice 58 Nov 27, 2013 11:45 AM
Tutorial: How to get PCSX2 to run on Mac (without BootCamp) Mirrors Mac Applications and Mac App Store 22 Jun 14, 2013 08:19 PM
IPHONE 4 how to JAILBREAK AND UNLOCK bs2511feist Jailbreaks and iOS Hacks 6 Apr 14, 2012 05:52 PM
Does anybody know how to get TweetTask? xmelissaxmayhem Jailbreaks and iOS Hacks 3 Jul 3, 2011 01:21 AM
[HOW TO] DIY iPhone 4 Swivel Car Mount QuarterSwede iPhone Accessories 13 Mar 8, 2011 02:51 PM


All times are GMT -5. The time now is 09:15 PM.

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

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