On Sun, Oct 19, 2008 at 08:51, Jeff Pang <[EMAIL PROTECTED]> wrote:
> 2008/10/19 itshardtogetone <[EMAIL PROTECTED]>:
>> Hi,
>> What is the command to recall the drive location of my script?
>> Thanks
>
> use Cwd;
> see getcwd();
snip

That will tell you where the script was run from (and maybe not even
that if chdir* is called before getcwd), but not where the script is.
The Find::Bin** module will tell you where the Perl script resides:

[EMAIL PROTECTED]:~$ cat /tmp/t.pl
#!/usr/bin/perl

use strict;
use warnings;
use FindBin;

use Cwd;

print getcwd(), "\n";

print "I look like I am in $FindBin::Bin and I am really in
$FindBin::RealBin\n";
[EMAIL PROTECTED]:~$ perl /tmp/t.pl
/Users/cowens
I look like I am in /private/tmp and I am really in /private/tmp

* http://perldoc.perl.org/functions/chdir.html
** http://perldoc.perl.org/FindBin.html

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to