Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to locate my script file itself when it is called by others.

Reply
Thread Tools

How to locate my script file itself when it is called by others.

 
 
MorningStar
Guest
Posts: n/a
 
      08-02-2005
I wrote a perl script and it will be called by other modules.
Now I need to know where I(my script) am when I am called.
For example: If my script located in:
/home/morningstar/a.pl
And some one called it from:
[home/someone]$ /home/morningstar/a.pl
or even
[home/someone]$ a.pl (if /home/morningstar is in $PATH ENV)

Then when a.pl was executed, how can it get its location:
"/home/morningstar/"?

If you don't understand what do I mean, just imagin the functionality
of 2 Windows API: GetModuleFileName and GetModuleFileNameEx.

Thanks.

 
Reply With Quote
 
 
 
 
John W. Krahn
Guest
Posts: n/a
 
      08-02-2005
MorningStar wrote:
> I wrote a perl script and it will be called by other modules.
> Now I need to know where I(my script) am when I am called.
> For example: If my script located in:
> /home/morningstar/a.pl
> And some one called it from:
> [home/someone]$ /home/morningstar/a.pl
> or even
> [home/someone]$ a.pl (if /home/morningstar is in $PATH ENV)
>
> Then when a.pl was executed, how can it get its location:
> "/home/morningstar/"?


perldoc FindBin


John
--
use Perl;
program
fulfillment
 
Reply With Quote
 
 
 
 
MorningStar
Guest
Posts: n/a
 
      08-02-2005
3x

 
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
obtain element name, or attribute and value of the document name itself, and some elemnts and attributes from an ancestor or the node itself using xquery Jeff Kish XML 4 10-30-2008 05:47 PM
Alter String base class to perform new (private methods) beforereturning itself when called by print statements Steven G. Harms Ruby 7 02-17-2008 04:23 PM
Where to locate index page perl script zaphod Perl Misc 7 06-21-2005 04:21 PM
Can Python Module Locate Itself? sj Python 6 09-18-2003 07:39 AM



Advertisments