Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Quick Perl Help, Please

Quick Perl Help, Please
Thread Tools
immsav
Fresh-Faced Recruit
Join Date: Dec 2002
Location: Oxford
Status: Offline
Reply With Quote
May 15, 2003, 10:43 PM
 
I'm trying to learn Perl, but I can't get this simple script to work:

<script>
#!/usr/bin/perl -w

print "Hello World";
</script>

When I save it to my desktop as test.pl and try to run it from the terminal by typing, "perl test.pl", I get nothing. Changing the file permissions doesn't help, either.

Any ideas?

Thanks,

Jacob
     
Paul McCann
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status: Offline
Reply With Quote
May 15, 2003, 11:06 PM
 
Originally posted by immsav:

Any ideas?
Maybe you've saved the script with old-style mac line endings? Perl on OSX requires line feeds as line endings, so check that your text editor is saving things using "unix line endings" and you should be fine.

(You can check that perl is working fine using the one line equivalent of what you posted. Open a terminal window and enter

perl -e 'print "Hello world\n" '

Good luck,
Paul
     
kman42
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
May 15, 2003, 11:09 PM
 
Originally posted by immsav:
I'm trying to learn Perl, but I can't get this simple script to work:

<script>
#!/usr/bin/perl -w

print "Hello World";
</script>

When I save it to my desktop as test.pl and try to run it from the terminal by typing, "perl test.pl", I get nothing. Changing the file permissions doesn't help, either.

Any ideas?

Thanks,

Jacob
Sorry, dude. I just cut/paste your script and it worked fine after a chmod. After all, it should. It has correct syntax. Are you missing perl for some reason?

kman
     
immsav  (op)
Fresh-Faced Recruit
Join Date: Dec 2002
Location: Oxford
Status: Offline
Reply With Quote
May 16, 2003, 12:02 AM
 
It was the Unix line-endings; it works now. Thanks.

-JLP
     
   
Thread Tools
 
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -4. The time now is 02:52 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,