Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > current path

Reply
Thread Tools

current path

 
 
Jochen Friedmann
Guest
Posts: n/a
 
      09-17-2003
Hello together,

how can I find the current path my Perlscript is started ?

Jochen


 
Reply With Quote
 
 
 
 
Andreas Kahari
Guest
Posts: n/a
 
      09-17-2003
In article <bk9jel$nic$(E-Mail Removed)>, Jochen Friedmann wrote:
> how can I find the current path my Perlscript is started ?


See the documentation for the FindBin module.


--
Andreas Kähäri
 
Reply With Quote
 
 
 
 
Thens
Guest
Posts: n/a
 
      09-17-2003
"Jochen Friedmann" <(E-Mail Removed)> wrote:

# how can I find the current path my Perlscript is started ?

I dont know what you meant by the current path.

If it is the current directory, you can get the current working
directory like this

use Cwd;
my $dir = cwd();

You can get the full path to the script name from the variable $0 and
then if you do a basename on it you can get the path to the directory
where the script is present.

example :
script : /home/abc/scripts.pl

#!/usr/bin/perl

use strict;
use warnings;
use File::Basename;
my $dir = File::basename($0);

--
Thens.



 
Reply With Quote
 
Paanwa
Guest
Posts: n/a
 
      09-17-2003

"Jochen Friedmann" <(E-Mail Removed)> wrote in message
news:bk9jel$nic$(E-Mail Removed)...
> Hello together,
>
> how can I find the current path my Perlscript is started ?
>
> Jochen
>
>


You can also get this information from Environment Variables....check out
http://www.devdaily.com/perl/edu/art...pl020001.shtml

PAW


 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      09-17-2003
Paanwa <(E-Mail Removed)> wrote:
> "Jochen Friedmann" <(E-Mail Removed)> wrote in message
> news:bk9jel$nic$(E-Mail Removed)...



>> how can I find the current path my Perlscript is started ?



> You can also get this information from Environment Variables....check out
> http://www.devdaily.com/perl/edu/art...pl020001.shtml



Perl is not CGI.

The OP made no mention of what environment his Perl program runs in...


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      09-18-2003
Jochen Friedmann wrote:
> how can I find the current path my Perlscript is started ?


Please define "current path".

If you are talking about the current working directory, then please have a
look at Cwd::cwd.
If you are talking about the location of the Perl script in your filesystem,
then please check $FindBin::Bin.
Or $0.

Either of them may or may not work for your specific requirements.

jue


 
Reply With Quote
 
Richard S Beckett
Guest
Posts: n/a
 
      09-18-2003
> how can I find the current path my Perlscript is started ?


use Cwd;
my $pwd = cwd; $pwd =~ s!/!\\!g;
print "Current path is $pwd\n";

--
R.
GPLRank +79.699


 
Reply With Quote
 
Paanwa
Guest
Posts: n/a
 
      09-18-2003

> Perl is not CGI.
>
> The OP made no mention of what environment his Perl program runs in...


Hi Tad,

Thanks for pointing this out. I've not yet seen an environment with ENV
can't return the script path - there are always exceptions. Can anyone tell
me if there are performance consideration in using ENV vs Cwd?

PAW


 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      09-18-2003
Paanwa <(E-Mail Removed)> wrote:
>
>> Perl is not CGI.
>>
>> The OP made no mention of what environment his Perl program runs in...

>
> Hi Tad,
>
> Thanks for pointing this out.



Is your Perl programming running in the CGI environment or is it not?


> I've not yet seen an environment with ENV
> can't return the script path -



I have no idea what you are talking about.

We have asked you before to clarify what you meant by "script path",
please try and do that.

I can't tell if you want the current working directory, or the
location of your program file in the filesystem, or the URL for
some CGI program.

Which one is it that you are trying to find?

There are potentially lots and lots of environment variables,
which one is it that you are talking about? I assumed it
was $ENV{PWD}...


> there are always exceptions. Can anyone tell
> me if there are performance consideration in using ENV vs Cwd?



Now I am even more confused about what it is that you are asking.

If you are asking about the "current working directory", then why
do you keep mentioning the location of the program file?

Where your program file exists in the filesystem is not related
to what your current working directory is.

We must understand what you are asking for before we can help
you find it.

Try again explaining what it is that you are asking for.


--
Tad McClellan SGML consulting
(E-Mail Removed) Perl programming
Fort Worth, Texas
 
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
using the current method name within current method Matthew Heidemann Ruby 14 03-22-2011 03:56 AM
printing out the current URL for current ASP page in Perl Jack Perl Misc 3 12-22-2008 02:35 PM
Thread.current.parent and Thread.current.ancestors ara.t.howard@noaa.gov Ruby 3 02-16-2007 03:34 PM
How to update the current web page? (delete current web page + rewrite the page) laryten@yahoo.com Javascript 3 10-12-2006 07:33 PM
How to change the current thread current culture at run time. Manu ASP .Net 1 07-20-2003 03:27 PM



Advertisments