Path: utzoo!utgpu!news-server.csri.toronto.edu!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: dirname (was path truncation) Message-ID: <5807@male.EBay.Sun.COM> Date: 22 Mar 91 15:49:20 GMT Sender: news@male.EBay.Sun.COM Lines: 18 This is an implementaion of dirname(1v) that I use that will do the trick. sub DirName { # DirName ($dir) local ($_, $return) = @_; s#$#/#; (($return) = m#^(/)[^/]*/$#) || (($return) = m#(.*[^/])/+[^/]+/+$#) || ($return = '.'); $return; } 1; And this is an example of how I do basename(1): ($MYNAME) = $0 =~ /([^\/]+)$/; Wayne