Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default current path

    Hello together,

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

    Jochen


    Jochen Friedmann Guest

  2. Similar Questions and Discussions

    1. Finding the current path
      Octavian Rasnita wrote: Use the standard Cwd module.
    2. #25444 [Bgs->Opn]: php4isapi.dll path to win.ini doesn't load from current path.
      ID: 25444 User updated by: ict at primus dot ca Reported By: ict at primus dot ca -Status: Bogus +Status: ...
    3. #25444 [Opn->Bgs]: php4isapi.dll path to win.ini doesn't load from current path.
      ID: 25444 Updated by: sniper@php.net Reported By: ict at primus dot ca -Status: Open +Status: Bogus...
    4. #25444 [NEW]: php4isapi.dll path to win.ini doesn't load from current path.
      From: ict at primus dot ca Operating system: W2K PHP version: 4.3.3 PHP Bug Type: *Configuration Issues Bug description: ...
    5. [PHP] get current path
      Hi, The PHP site seems to be down right now ... so here's the question: Is it possible for PHP to tell me the current path of a page? For...
  3. #2

    Default Re: current path

    In article <bk9jel$nic$1@ns2.fe.internet.bosch.com>, 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
    Andreas Kahari Guest

  4. #3

    Default Re: current path

    "Jochen Friedmann" <jochen.friedmann2@de.bosch.com> 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.



    Thens Guest

  5. #4

    Default Re: current path


    "Jochen Friedmann" <jochen.friedmann2@de.bosch.com> wrote in message
    news:bk9jel$nic$1@ns2.fe.internet.bosch.com...
    > 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
    [url]http://www.devdaily.com/perl/edu/articles/pl020001.shtml[/url]

    PAW


    Paanwa Guest

  6. #5

    Default Re: current path

    Paanwa <paanwa@hotmail.com> wrote:
    > "Jochen Friedmann" <jochen.friedmann2@de.bosch.com> wrote in message
    > news:bk9jel$nic$1@ns2.fe.internet.bosch.com...
    >> how can I find the current path my Perlscript is started ?
    > You can also get this information from Environment Variables....check out
    > [url]http://www.devdaily.com/perl/edu/articles/pl020001.shtml[/url]

    Perl is not CGI.

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


    --
    Tad McClellan SGML consulting
    [email]tadmc@augustmail.com[/email] Perl programming
    Fort Worth, Texas
    Tad McClellan Guest

  7. #6

    Default Re: current path

    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


    Jürgen Exner Guest

  8. #7

    Default Re: current path

    > 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


    Richard S Beckett Guest

  9. #8

    Default Re: current path

    > 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


    Paanwa Guest

  10. #9

    Default Re: current path

    Paanwa <paanwa@hotmail.com> 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
    [email]tadmc@augustmail.com[/email] Perl programming
    Fort Worth, Texas
    Tad McClellan Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139