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

Discussion in 'Perl Misc' started by MorningStar, Aug 2, 2005.

  1. MorningStar

    MorningStar Guest

    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.
     
    MorningStar, Aug 2, 2005
    #1
    1. Advertisements

  2. perldoc FindBin


    John
     
    John W. Krahn, Aug 2, 2005
    #2
    1. Advertisements

  3. MorningStar

    MorningStar Guest

    3x
     
    MorningStar, Aug 2, 2005
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.