Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Corrosive vinyl

macrumors 6502
Original poster
Sep 22, 2006
473
0
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.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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>
 

Corrosive vinyl

macrumors 6502
Original poster
Sep 22, 2006
473
0
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!
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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.
 

iSee

macrumors 68040
Oct 25, 2004
3,539
272
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.
 

cube

Suspended
May 10, 2004
17,011
4,972
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
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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.

My Terminal said:
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

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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.
 

cube

Suspended
May 10, 2004
17,011
4,972
You said:

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 "."
 

Corrosive vinyl

macrumors 6502
Original poster
Sep 22, 2006
473
0
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...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.