Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How can I find program location?

Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!dispose.news.demon.net!demon!diablo.theplanet.net!easynet-monga!easynet.net!server5.netnews.ja.net!news.swman.net.uk!not-for-mail
From: Wiliam Stephens <w...@stephens.org>
Newsgroups: comp.lang.perl.misc,comp.lang.perl.modules
Subject: Re: How can I find program location?
Date: Fri, 21 Dec 2001 11:02:56 +0000
Organization: University of Wales, Aberystwyth
Lines: 25
Message-ID: <3C2316E0.3040600@stephens.org>
References: <9vuehq$g5j$1@panix3.panix.com>
NNTP-Posting-Host: dyfi.aber.ac.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: mannews.swan.ac.uk 1008932499 23125 144.124.16.27 (21 Dec 2001 11:01:39 GMT)
X-Complaints-To: usenet@news.swman.net.uk
NNTP-Posting-Date: 21 Dec 2001 11:01:39 GMT
To: John Brock <jbr...@panix.com>
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.6) Gecko/20011120
X-Accept-Language: en-us
Cache-Post-Path: dyfi.aber.ac.uk!unkn...@pcbich.ott.aber.ac.uk
X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/)

[ posted and mailed ]

John Brock wrote:
 > [ snip ]
 >
 > Alternatively, is there a better and more standard way to do what
 > I am trying to do?


Standard? We're talking Perl here. TMTOWTDI.


I'm using the following code, it works for me. Hope this helps!


	if    ($0=~m#^(.*)\\#){ $cgidir = "$1"; }  # Win32/DOS
	elsif ($0=~m#^(.*)/# ){ $cgidir = "$1"; }  # Unix
	else  {`pwd` =~ /(.*)/; $cgidir = "$1"; }  # Unix

You need the last else line as some unix servers don't put the full file 
path into the $0 variable.

-- 
Wiliam Stephens <w...@stephens.org>>