Re: Finding directory my perl program was loaded from

Discussion in 'Perl' started by Jürgen Exner, Oct 13, 2009.

  1. [comp.lang.perl has been rm-grouped some 15 years ago. If your ISP still
    carries this instead of comp.lang.perl.* you should wonder what else you
    are missing.]
    [x-post and f'up to comp.lang.perl.misc]

    Joe Green <> wrote:
    >I will put my template file in the same directory that my perl program was loaded from. Is there a reasonable way to determine this directory?


    See the second and following parts of "perldoc -q directory":
    "How do I add the directory my program lives in"

    >Then internally I will (if I get a little help) access "fullPath...template.txt". Until I find out how to do this that line from my patch file will read like . . .
    >
    >Perl "fullPath...xlate.pl" "fullPath...translate.txt" user.asm >temp.asm


    If you don't call the perl interpreter explicitely but just use
    "fullPath...xlate.pl ..." then you should find the full path in $0.
    Extracting the directory from $0 is trivial using functions from
    File::Basename

    >I would prefer to not use path environment settings.


    Well, $ENV{PATH} does play a major role in deciding which executables to
    use, so you cannot just ignore it.

    jue
     
    Jürgen Exner, Oct 13, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcelo Birnbach [MS]
    Replies:
    0
    Views:
    3,364
    Marcelo Birnbach [MS]
    Jun 28, 2003
  2. Udo Corban
    Replies:
    0
    Views:
    3,933
    Udo Corban
    Jan 23, 2004
  3. Jay
    Replies:
    5
    Views:
    1,054
    Mike Wahler
    Dec 22, 2005
  4. Fei Liu
    Replies:
    2
    Views:
    2,091
  5. Fei Liu
    Replies:
    2
    Views:
    440
    -berlin.de
    Mar 28, 2007
Loading...

Share This Page