in reply to I come in peace for I seek your wisdom dear monks :)
$ perl helloworld.pl and the book shows that it's supposed to show up on the screen as Hello World! Thats really where I run into my problem. You see, every time I try to run it, it tells me it cannot be ran, because no such files or directory exist.
On a Unix system, in order to execute a Perl script, it has to have what is called "execute" permission. Each file has "read, write, execute" permission levels for each of "user, group, other". "man" (short for manual) is a command that you will become very familiar with! Type "man chmod" at the command prompt.
chmod 755 helloworld.pl is a common thing to do and this results in (-rwxr-xr-x), meaning that you as a user have rwx (read,write,execute permissions) to this file, the group that you belong to has r-x (read and execute, but not write)and all others have have the same permission (r-x) as your group. The first dash - at the beginning has special meaning that is not important now.
At the command prompt, type "ls -al". This should show the files and directories and this rwxrwxrwx notation, each rwx "set" is 3 bits in octal and is for user,group, other. 755 in octal is 111 101 101, the "write" bit is turned off for the group and for others, but is turned on for "user", meaning you. This scenario is common.
Now that you have the helloworld.pl program marked as exectuable (chmod 755 helloworld.pl). A Unix system looks into the file in order to decide what to do. That is why the first line in that file should be:
#!/usr/bin/perl
This is called the "shebang" line. The # means that this is a comment..sort of..except when its not..and this is one of those cases. This looks like a comment, but it is way more than a comment. As the first line, this means: run the Perl interpreter on the rest of this file.
Once you have given execute permission to the file, you can just type "helloword.pl" and it will run. Typing "perl helloworld.pl" explicitly starts the Perl interpreter and sends it the helloworld.pl file. Oh, also be aware that Unix is case sensitive. Helloworld.pl is different than helloworld.pl
Get helloworld.pl working in your default login directory before trying to move it or get it to run in a sub-directory.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: I come in peace for I seek your wisdom dear monks :)
by JavaFan (Canon) on Dec 08, 2010 at 10:59 UTC | |
by Marshall (Canon) on Dec 08, 2010 at 12:53 UTC | |
by JavaFan (Canon) on Dec 08, 2010 at 13:43 UTC | |
|
Re^2: I come in peace for I seek your wisdom dear monks :)
by Argel (Prior) on Dec 08, 2010 at 19:20 UTC | |
by Marshall (Canon) on Dec 10, 2010 at 09:42 UTC |