Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!sun-barr!newstop!male!anywhere.EBay.Sun.COM!me From: me@anywhere.EBay.Sun.COM (Wayne Thompson - IR Workstation Support SE) Newsgroups: comp.lang.perl Subject: Re: pwd? Message-ID: <6330@male.EBay.Sun.COM> Date: 17 Apr 91 12:58:55 GMT Sender: news@male.EBay.Sun.COM Lines: 27 Here's what I use to get an absolute path. As always, comments welcomed. Wayne sub FullPath { # FullPath ($name) local ($name, $path, $dir) = @_; if ($name =~ m#^/#) { $path = $name; } elsif ($name !~ m#/#) { foreach $dir (split (/:/, $ENV{'PATH'})) { $path = join ('/', $dir, $name); last if -x $path && -f _; $path = ''; } } else { chop ($dir = `pwd`), $path = join ('/', $dir, $name); } chop ($dir = `pwd`), $path = join ('/', $dir, $name) if $path eq "./$name"; $path =~ s#[^/]+/\.\.##go; $path =~ s#\./##go; $path =~ s#//#/#go; $path; } 1;