BBEdit is a good choice if you're looking for an editor for MacOSX.
For what concerns your other doubts, I think perlintro is a good starting point. The examples you'll find there are meant to be written in a file, then run from the command line. For example, once you saved in a file called example.pl a program like this:
print "Hello world!\n";
you will run it from the command line with something like this (I'm faking your own situation to be more clear):
[Ordinateur-de-me-XoX:~] exox% perl example.pl
Hello world!
[Ordinateur-de-me-XoX:~] exox%
And so on, they're all variations on the same theme.
Another note...
[Ordinateur-de-me-XoX:~] exox% print "Hello World!\n";
print: Command not found.
[Ordinateur-de-me-XoX:~] exox%
This does not work 'cause you're speaking Perl to to someone who does not understand Perl, the shell. Through the shell you can only "call" someone who can understand the Perl language, that is the Perl interpreter. It is precisely what you're doing when you type from the command line:
[Ordinateur-de-me-XoX:~] exox% perl example.pl
| [reply] [Watch: Dir/Any] [d/l] [select] |
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. | [reply] [Watch: Dir/Any] [d/l] [select] |
In addition to BBEdit (which available in a pay version and a time-limited 'demo' version), Mac OS X also comes with Emacs and vi.
Both Emacs and vi run in Terminal. They are completely text based and don't have a graphical interface (well, they can, but we're not gonna talk about installing X and Fink). There are GUI based editors that are free (like JEdit).
You can read an Emacs tutorial here.
Vi tutorial available here.
You'll need to enter the examples in a text editor and then save it (perhaps as 'hello.pl'.
After saving the example, you run it by typing 'perl hello.pl'.
Welcome to Perl! Perlmonks is here to help, but please read documentation before asking a question. If you don't like reading docs in a Terminal, try perldoc.com.
| [reply] [Watch: Dir/Any] |