Forest BB

The digital grapevine of The Forest.
It is currently Sun Sep 21, 2014 2:09 pm

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Perl help
PostPosted: Mon Aug 13, 2007 9:18 pm 
Offline
User avatar

Joined: Fri Aug 27, 2004 2:26 pm
Posts: 427
Location: cyberspace. Berlin
hello friendly forest geeks!

can anyone gimme some tips on learning Perl? i need it for a project ive been asked to help on... have a good beginners tutorial from perl.com but i still dont have anyway to run Perl scripts...? i need an interpreter? apparently there should be one pre-installed on my mac os x, but i dont find nothing, tried to install something called ActivePerl but i cant find the .app although its said installation successful... oh dear, pogo/swithun/chombee - if any you guys are around end of august when i come for connect festival, i need to talk!

stay cool,

Drock

_________________
"If something is boring after two minutes, try it for four. If still boring, then eight. Then sixteen. Then thirty-two. Eventually one discovers that it is not boring at all." --John Cage.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 13, 2007 9:33 pm 
Offline
User avatar

Joined: Wed Mar 29, 2006 11:24 am
Posts: 2615
It is probably easiest if you open up a terminal and run the script from there. I've never used OS X, so I'm not sure about directory layout. But if you save the script in your home directory, you should be able to find it from inside the terminal.

I'm going to France on the 29th, but if you are here before then, I can help out.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 13, 2007 9:51 pm 
Offline
User avatar

Joined: Fri Aug 27, 2004 2:26 pm
Posts: 427
Location: cyberspace. Berlin
yeah, right - i'm in terminal...trying to run very simple things..just getting "No such file or directory"....ach, i'll just keep banging my head against the cyber wall - im sure this is something one has to do alone. but arent i too old to be getting into this shit?

have fun in france swithers!

big up, Drock

_________________
"If something is boring after two minutes, try it for four. If still boring, then eight. Then sixteen. Then thirty-two. Eventually one discovers that it is not boring at all." --John Cage.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 9:26 am 
Offline
User avatar

Joined: Mon Sep 11, 2006 12:35 pm
Posts: 1084
The Llama Book is a good introduction. I have a copy around somewhere, will have a look.[/url]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 9:43 am 
Offline
User avatar

Joined: Wed Mar 29, 2006 11:24 am
Posts: 2615
The first line of the Perl script should be the shebang line. It specifies the location of the Perl interpreter. On my machine, Perl is in /usr/bin. You can find out where yours is with the command

Quote:
[swithun@abednego ~]$ which perl
/usr/bin/perl


So, the line is
Code:
#!/usr/bin/perl


If your Perl is in one place, and the shebang line says something different, that could be why you are getting the error.

Or, the Perl interpreter is found, but your script isn't. I don't know how OS X splits the Mac side from the Unix side. Try commands like ls and pwd to work out where in the system you are from the terminal and move your Perl scripts to that location. Or, see what text editors you have access to from the terminal and do it all from there.

This page might help with your Active Perl installation, if the default one isn't working for you.

Don't give up.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 10:38 am 
Offline
User avatar

Joined: Fri Aug 27, 2004 2:26 pm
Posts: 427
Location: cyberspace. Berlin
thanks for the tips fellas. yeah, i have to figure out the paths.
terminal is not my/a perl interpreter?
i wont give up. martin, you still comin' to berlin for the ccc meet? get in touch if youre over here...!

_________________
"If something is boring after two minutes, try it for four. If still boring, then eight. Then sixteen. Then thirty-two. Eventually one discovers that it is not boring at all." --John Cage.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 10:50 am 
Offline
User avatar

Joined: Mon Sep 11, 2006 12:35 pm
Posts: 1084
I was just over there for the CCC camp! Will be back in December for the congress.

Terminal is just a window running your shell, the program that takes commands and runs them. If you run 'perl' from there, that's your interpreter. If you have a script you want to run, saved in a file, 'perl <filename>' will make it run it. This is the easiest way. <filename> can be the name of a file in the current directory (e.g. myscript.pl), or the full path to a file anywhere on the system (e.g. /Users/thehemulen/Desktop/myscript.pl)

If you have #!/usr/bin/perl (or wherever your perl interpreter actually is on the system) at the top of your script, you can run it directly from the shell without typing 'perl', because the #! line tells the system what interpreter to run it with. To do this the script file must be marked as executable, which can be done with the command 'chmod +x <filename>'. Then to run it, you just type the filename at the shell, either with the full path or with './' to indicate the current directory, e.g. './myscript.pl'.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 11:00 am 
Offline
User avatar

Joined: Fri Aug 27, 2004 2:26 pm
Posts: 427
Location: cyberspace. Berlin
phew! all i needed was to put the .pl files in users/dirk....!!! now its hunky dory!
working my way thru this intro guide: http://www.perl.com/pub/a/2000/11/begperl2.html
do you guys actually work with perl? what for/on?

_________________
"If something is boring after two minutes, try it for four. If still boring, then eight. Then sixteen. Then thirty-two. Eventually one discovers that it is not boring at all." --John Cage.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 11:06 am 
Offline
User avatar

Joined: Fri Aug 27, 2004 2:26 pm
Posts: 427
Location: cyberspace. Berlin
great advice martin, thanks. sorry i missed you when you were just over here: definitely get in touch in dec - maybe by then i'll know enough to benefit from the congress too! : )

_________________
"If something is boring after two minutes, try it for four. If still boring, then eight. Then sixteen. Then thirty-two. Eventually one discovers that it is not boring at all." --John Cage.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 15, 2007 3:07 pm 
Offline
User avatar

Joined: Wed Mar 29, 2006 11:24 am
Posts: 2615
I don't do much with Perl these days. I used to write everything in Perl, but then I realised that it was easier to learn new languages which were better suited to different jobs than it was to try and do everything in one language.

So now I write stuff in PHP (for website stuff), Python (for rapid development of complex stuff), C (when speed of running is more important than speed of development), XSLT (for transforming data), Bash (for automating repetitive tasks) etc.. And I use Perl for quick text transforming jobs, which are too much for sed/grep.

I think learning Perl is worth it. You get to cover the basics which are common to almost all languages. But then you are able to appreciate all the good bits of other languages. PHP has useful functions because it was designed for a certain job. Python looks much nicer and is easier to read.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group