It seems that you're having as much trouble understanding the unix command line (the "brand new feature" for macs, introduced in OS X, which everyone else has been using for decades), as you are getting started with perl scripting.

It appears that your system uses the string "exox%" as the "command-line prompt" -- the final "%" is often a clue about what sort of "shell" is running to process your commands. Are you able to look up a "Help" page somewhere on your system that explains what the "shell" is, and how to use it? If so, it's likely to be a long explanation, and you should take the time to read it, even if it seems cryptic at first glance. Many linux and other unix users use the "bash" shell, which usually presents a prompt with a final "$" instead of a final "%" -- that's why Defyance suggested something that looked like "$ man perl" -- he included the command-prompt character, assuming you would understand it as such. (And when you type the entire string "$ man perl" as a command, your system thinks that "$" was supposed to be the name of an executable command, and naturally reported "$: Command not found", because there is no command called "$".

The command-line interface for OS X is basically just like any other unix command line interface. But, coming from the traditional GUI-only mac orientation, it may all seem too foreign and inexplicable at first. Remember this one thing about the command line, and you'll get a handle on it:

prompt-string% name_of_program -options arguments
The "prompt-string%" is the part that the shell prints to let you know it's waiting for your input; the first word you type is supposed to be the name of a command (ie. the name of a file that contains an executable program), like "ls", "man", "cp", "perl", "perldoc", or the name of a perl script file that you have created and made executable by putting
#!/usr/bin/perl
as the first line of your perl script file and running the command
chmod +x your_perl_script_file_name
to tell OS X that this should be treated as an eXecutable file.

"-options" are things that may or may not be needed to make a given command do what you want, and this depends on the command that you're running -- each command should have a "man page" (short for "manual page") viewable by typing man command_name as a command, e.g.

man cp
This will explain what the command does (the "cp" command in this example), as well as what options are available, and how they affect what the command does.

"arguments" are typically names of files that the command is supposed to operate on (read, write, etc), or they can be strings that pertain to particular options -- eg:

man man man -k directory
The first command "man man" says: print the man page for the "man" command. On that page, you'll see that the "-k" option can be used to list all commands that pertain to a given keyword. The second command above "man -k directory" demonstrates the use of the "-k" option -- it will list all commands that have anything to do with operating on directories.

Again, the syntax and possibilities for arguments will depend on the particular command, and the man page for each command will explain this.

As you write perl scripts that you want to execute from the command line, you will be able to design the script so that it can also accept options and arguments. These will be available to the script in the array @ARGV. Of course, the perl programs you write will not have man pages explaining their command-line usage, unless you write them yourself; luckily, perl's "plain old documentation" (pod) facility makes that pretty simple (try "man -k pod"). Have fun.


In reply to Re: begin w/ Perl OSX by graff
in thread begin w/ Perl OSX by Anonymous Monk

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.