He didn't ask "How do I get the current directory". He asked "How do I find the directory where the script is running". On a Mac this is, as Chris pointed out, usually the same thing (unless the script has not been saved to a file). On a Unix system the likelihood that these are the same varies wildly, from 100% (write and test in cwd) to 0% (script installed and running in a directory somewhere on the path). At 21:25 -0700 5/19/99, Peter Prymmer wrote: >> (Vicki wrote) >> If the script is called by a relative pathname, then $0 contains that >> relative path (and you have to figure out the location by where it is in >> terms of the current directory.) > > ?? !! :-) I don't see any use of $0 in the snippet below... and I did especially specify "if you want portability... to systems that aren't Macs" ;) > > use Cwd; > > my $pwd = cwd; > > print "I think I am in $pwd\n"; > > __END__ > > on a Mac yields: > > I think I am in HD:MacPerl f: > > And seems to yield reasonable results on other platforms as well. Of course it does, and a nice bit of code too, if you want to determine the current working directory. But that's not what we want to do... we want to determine "the directory where the script is running" and we want to do it portably. The question was not "where am I?" but rather "where is the script?" The answers are likely to differ. -- -- |\ _,,,---,,_ 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