Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to directly get the script-path.

Reply
Thread Tools

How to directly get the script-path.

 
 
ZZT
Guest
Posts: n/a
 
      06-21-2004
Hi,

I'd like to get the directory of the currently running script (not the
working directory) but without concat constructs with $0 and getcwd().
Is there an easy way, an internal or ENV var?

thanks a lot
 
Reply With Quote
 
 
 
 
Sam Holden
Guest
Posts: n/a
 
      06-21-2004
On Mon, 21 Jun 2004 14:05:15 +0200, ZZT <(E-Mail Removed)> wrote:
> Hi,
>
> I'd like to get the directory of the currently running script (not the
> working directory) but without concat constructs with $0 and getcwd().
> Is there an easy way, an internal or ENV var?


perldoc -q "directory my program lives in"

--
Sam Holden
 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      06-21-2004
On Mon, 21 Jun 2004, ZZT wrote:

> Hi,
>
> I'd like to get the directory of the currently running script (not the
> working directory) but without concat constructs with $0 and getcwd().
> Is there an easy way, an internal or ENV var?
>
> thanks a lot



You might want a combination of File::Basename::dirname and
File::Spec::rel2abs. Something like this, perhaps:

[untested]
#!/usr/bin/perl
use strict;
use warnings;
use File::Basename;
use File::Spec;

my $dir = File::Spec->rel2abs(dirname($0));

print "$dir\n";


Paul Lalli
 
Reply With Quote
 
John J. Trammell
Guest
Posts: n/a
 
      06-21-2004
On Mon, 21 Jun 2004 14:05:15 +0200, ZZT <(E-Mail Removed)> wrote:
> I'd like to get the directory of the currently running script (not the
> working directory) but without concat constructs with $0 and getcwd().
> Is there an easy way, an internal or ENV var?


perldoc FindBin

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
get image data from dataset (insead of directly from db) MattB ASP .Net 2 05-04-2004 08:55 PM
NO Exam!! Get your Cert directly! ipassmcse MCSD 1 02-20-2004 11:02 PM
Preview image directly on PC, save directly to HD Patrick M. Digital Photography 3 01-07-2004 08:29 PM
Get Hashtable Object Directly John E ASP .Net 1 10-08-2003 12:40 PM



Advertisments