|
|
Quick Perl Help, Please
|
|
|
|
Fresh-Faced Recruit
Join Date: Dec 2002
Location: Oxford
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Dec 2002
Location: Oxford
Status:
Offline
|
|
It was the Unix line-endings; it works now. Thanks.
-JLP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|