$ 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.


In reply to Re: I come in peace for I seek your wisdom dear monks :) by Marshall
in thread I come in peace for I seek your wisdom dear monks :) by Samurai Monkey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.