At 09:16 AM 7/27/2004, Nick Pappas wrote:
I am just learning to use Perl on OS 10.3. I am not an experienced Unix programmer, so I am probably doing something very basically wrong.

You'll get there.

My first "Hello World" script is not executing. I created a Plain Text script using TextEdit and saved it in my Documents folder with the name "simple_print".

In Terminal, I give a pwd command and get back the reply: /Users/username

This is telling you that the full path to your Documents folder is actually /Users/username/Documents.


When I type: perl /Documents/simple_print, I get the diagnostic
Can't open perl script "/Documents/simple_print": No such file or directory

Unix paths are constructed starting from a root directory. The name of that root directory is "/".


If you want to use a relative path, that is one that does not start from "/", you need to indicate that you are building a relative path. This is done with one of a few different characters - either ".", or "~" usually. "~" means "Relative to my home directory", and "." means "relative to the current directory.

So you could cd to /, and then "perl ~/Documents/simple_print", and that would be the same as "perl /Users/username/Documents/simple_print". Or you could cd (or not, since you're starting there) to /Users/username, and say "perl ./Documents/simple_print". (notice the period before the first slash), and that would also be equivalent to "perl /Users/username/Documents/simple_print".

But if you were cded to somewhere else like '/etc/mail', then "perl ./Documents/simple_print" would be equivalent to "perl /etc/mail/Documents/simple_print" where "perl ~/Documents/simple_print" will always be equivalent to "perl /Users/username/Documents/simple_print".

-jeff lowrey
who probably is not the first or only person to answer this, and his message will likely show up late






Reply via email to