in reply to Using Perl on OS X

The $ actually is the shell symbol, you shouldn't really type it, it's there to indicate that you are typing this on a shell... as for not returning anything, that's what the chmod does... it returns something only when it fails, you can now see if it worked by doing

$ ls -l my_program

without the $ of course ;) you'll see the file with the permissions it has

now you do: ./my_program and it should work.


He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

Chady | http://chady.net/

Replies are listed 'Best First'.
Re: Using Perl on OS X
by 1st_try (Initiate) on Sep 13, 2002 at 05:55 UTC

    Thanks!

Re: Using Perl on OS X
by 1st_try (Initiate) on Sep 13, 2002 at 06:19 UTC

    Thanks for the response, everyone. However, my Terminal is still not displaying "Hello, world!" This is the code to my program:

    #!usr/bin/perl print "Hello, world!\n";

    I'm assuming this is all I need to type, right?

    I would type "my_program" or "perl my_program" after "chmod a+x my_program". The latter would cause the Terminal to respond: "my_program: Command not found." The former would just ignore it and ask for a new command without displaying "Hello, World!"

    Any thoughts?!?? Thanks.

      Try changing   #!usr/bin/perl to   #!/usr/bin/perl and see what happens then when you type ./my_program

      You're running into a set of problems that are common to first-time Unix users. Things might go quite a bit better for you if you can find someone who is familiar with Unix or OS X, and buy them a beer/coffee/whatever in exchange for an hour tour.

        I 2nd dws's response - the very 1st thing you need to do is find out where Perl is installed. I have no experience on OS X, but, try
        perl -V
        at a command prompt - that will print out the @INC array, which tells you the directories that Perl will search for modules.

        Also, on Linux you can do
        which perl
        at a command prompt. That will display something like this:
        /usr/bin/perl
        and that is what you should include in your #! line at the very top of each perl script. #!/usr/bin/perl -w.

        Once you've got that shebang line right, then if you do
        chmod +x my_program and then ./my_program it should run - hopefully.
        Again, I have no experience with OS X, so I don't know how much similarity it has to Unix/Linux.

        HTH.
        Or, if you're a book person (which your tale suggests), get a book about it. Oreilly even has a unix for OS X book now.