Thanks! I actually have a few more questions:
When I type "chmod a+x my_program" (no $ sign) am I supposed to get some response? It didn't seem to return anything. I then typed "perl my_program" and again, no response. Am I supposed to see a "Hello, world!" line pop up? If not, can someone provide me a simple Perl code that will create a response?
One more question: I'm supposed to start every new script with: #!usr/bin/perl right? I've double-checked already and made sure Perl is in that directory!
Thanks!
| [reply] [d/l] |
When I type "chmod a+x my_program" (no $ sign) am I supposed to get some response?
No. That chmod call sets a bit in your file's directory entry that marks it as executable by all users. That way, when you type ./my_program, the system knows it can execute your script. There's usually no response.
If you're curious, you can type man chmod; that will explain the various bits that can be set to allow reading, writing, and executing the file for the owner, his group, or all users.
One more question: I'm supposed to start every new script with: #!usr/bin/perl right? I've double-checked already and made sure Perl is in that directory!
Correct! The '#!' tells the system that you're about to tell it what program to use to run the file.
You could add a -w to that line if you want to run your program with warnings enabled. The "canonical" way to start a script is:
#!/usr/bin/perl -w
use strict;
use strict turns on additional features like errors for undeclared variables.
If you're using a more recent perl, you could replace the -w with "use warnings;", but I think that can wait until you get through your first perl book.
Good luck!
--
Mike | [reply] [d/l] |