At 23:17 -0400 5/20/99, Ronald J Kimball wrote: > If the current working directory is not the directory where the script is > running, then what is it exactly? I don't think we are using these terms > in the same way. this reminds me of "The Princess Bride" :-) "You keep using that word. I do not think it means what you think it means" :-) > I don't think we are using these terms in the same way. Probably not. However, since the term "current working directory" is effectively meaningless under the Finder (and was invented long before the Macintosh :), I think I'm justified in using the term the way Unix, MPW, and other shell-oriented systems use it. I had begun thinking that this discussion belonged more on macperl-anyperl because I was specifically addressing the question of _portable code_ ... but then I remembered MPW :-) So this really _is_ a MacPerl discussion, because Chris' statement: At 20:29 -0400 5/18/99, Chris Nandor wrote: > Current directory is where the script is. It defaults to MacPerl's > location if the script is not saved to a file. applies to the standalone MacPerl _app_. The MPW Perl tool, however, works more like Unix, i.e. the current directory is where the USER is. Where the SCRIPT is, may be totally different. Under MPW (or Unix :), the "current directory" is where you are. The MacOS Finder analog (a pretty poor analog) would be the current window. But of course, you move the mouse to launch a command, so the window moves. The MacPerl app emulates the "current directory" in a world that really doesn't possess the concept of "current directory". In Unix, or MPW, or any command line / shell environment, you (the user) stay in a particular directory and run commands by typing their names. The shell finds the command on the command path and launches it. Even if the command is in a different directory (folder) than where you "are". So for example with MPW, I can sit in the shell window and ask "where am I now" dir mouse3*:Protected:Projex:MPW:MPW:vlb: I can look at the files and directories there files :seq2bio: shell_relnote.pdf Worksheet.vlb Note, no Perl scripts, no perl command here. The MPW perl command lives elsewhere: which perl mouse3*:Protected:Projex:MPW:MPW:Tools:perl even so, I can run it from "here" (my current working directory) and I don't have to "go" anywhere because the shell finds the program and launches it for me. It's one of the differences between a command interface and a click interface. perl -e 'print `pwd`;' mouse3*:Protected:Projex:MPW:MPW:vlb yep; that's where I am. Now suppose I have a Perl script that lives elsewhere which foo.plx mouse3*:Protected:Projex:MPW:MPW:Tools:foo.plx Here's the script: Perl -Sx "{0}" {"Parameters"}; Exit #!perl print "working directory is ", `pwd`, "\n"; # working directory print "script is in $0\n"; # path to script The first line tells MPW perl to execute the script with Perl. OK, the script is in the Tools folder (directory). I am in the vlb folder (directory). Let's run the script: foo.plx working directory is mouse3*:Protected:Projex:MPW:MPW:vlb script is in mouse3*:Protected:Projex:MPW:MPW:Tools:foo.plx So you can see that the "current directory" and the "place where the script resides" are NOT the same under MPW. They would be the same if I switched my current working directory to the Tools directory: dir mouse3*:Protected:Projex:MPW:MPW:Tools: foo.plx working directory is mouse3*:Protected:Projex:MPW:MPW:Tools script is in :foo.plx Hmmm... $0 is not the full path to the script anymore. If I want to determine the full path to the script, I need to combine my knowledge of the current directory with $0... simply using $0 does not give me the full path. Using the current directory does not guarantee the location of the script. As long as you stick to the standalone Perl app, current directory will be the same as where the script is running (bacause that was how Matthias implemented current directory). But to be portable (to Unix, say, or to MPW MacPerl), then it is NOT always the case that current directory is where the script is. It's possible. It's not assured. - Vicki -- -- |\ _,,,---,,_ Vicki Brown <vlb@cfcl.com> ZZZzz /,`.-'`' -. ;-;;,_ Journeyman Sourceror: Scripts & Philtres |,4- ) )-,_. ,\ ( `'-' P.O. Box 1269 San Bruno CA 94066 '---''(_/--' `-'\_) http://www.cfcl.com/~vlb http://www.macperl.org ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org