Hugh,

I used to do this very simply using $0, but that broke a couple of
ActivePerl updates ago (grrrr) so I rolled my own:

#=======================================
#!/usr/bin/perl
use CWD;
sub getzero {
  ( my $result = $0 ) =~ s/.*[\\\/]([^\\\/]+)$/$1/;
  $result;
}
sub winwhere {
  ( my $currdir = getcwd()) =~ s!/!\\!g;
       $currdir =~ s/\\+/\\/g;
  $currdir .= "\\";
}
### Figure out where and what I am
my $rundir = &winwhere();
my $runapp = $rundir . &getzero();
print "Here's where I'm running: $rundir\n";
print "This is my full path and name: $runapp\n";
#=======================================

This should be pretty straightforward, please let me know if I've
obfuscated something beyond legibility.  My main goal in writing this
was to make it work on just about any Windows system -- that's why I
did a few things that might look "extra".

-Brian

_________________________
Brian H. Oak   CISSP CISA
Acorn Networks & Security
<http://acornnetsec.com/>

________________________________

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Hugh Loebner
Sent: Monday, June 27, 2005 09:59
To: [EMAIL PROTECTED]
Subject: Finding current directory


Hello all,

How do I get the path name of the current directory?

In other words, how can I find out the name of the folder in which a
program is executing?

Thanks,

Hugh


_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to