How to get current directory path

Discussion in 'Perl Misc' started by moonhkt, Sep 1, 2009.

  1. moonhkt

    moonhkt Guest

    Hi All

    How to get current directory path ?

    e.g c:\temp

    how to using perl get current directory path ? "c:\temp"


    moonhkt
     
    moonhkt, Sep 1, 2009
    #1
    1. Advertising

  2. moonhkt

    J. Gleixner Guest

    moonhkt wrote:
    > Hi All
    >
    > How to get current directory path ?
    >
    > e.g c:\temp
    >
    > how to using perl get current directory path ? "c:\temp"



    perldoc Cwd
     
    J. Gleixner, Sep 1, 2009
    #2
    1. Advertising

  3. body { font: Helvetica, Arial, sans-serif; } p { font: Helvetica, Arial, sans-serif; } ..standout { font-family: verdana, arial, sans-serif; font-size: 12px; color: #993333; line-height: 13px; font-weight: bold; margin-bottom: 10px; } ..code { border-top: 1px solid #ddd; border-left: 1px solid #ddd; border-right: 2px solid #000; border-bottom: 2px solid #000; padding: 10px; margin-top: 5px; margin-left: 5%; margin-right: 5%; background: #ffffea; color: black; -moz-border-radius: 10px; } ..codedark { border-top: 10px solid #03f; border-left: 1px solid #ddd; border-right: 2px solid grey; border-bottom: 2px solid grey; padding: 10px; margin-top: 5px; margin-left: 5%; margin-right: 5%; background: black; color: yellow; -moz-border-radius: 10px; } #code { color: black; font-size: 14px; font-family: courier; padding-left: 5px; } #line-number { color: #804000; font-family: Arial; font-size: 14px; padding-right: 5px; border-right: 1px dotted #804000; } blockquote[type=cite] { padding: 0em .5em .5em .5em !important; border-right: 2px solid blue !important; border-left: 2px solid blue !important; } blockquote[type=cite] blockquote[type=cite] { border-right: 2px solid maroon !important; border-left: 2px solid maroon !important; } blockquote[type=cite] blockquote[type=cite] blockquote[type=cite] { border-right: 2px solid teal !important; border-left: 2px solid teal !important; } blockquote[type=cite] blockquote[type=cite] blockquote[type=cite] blockquote[type=cite] { border-right: 2px solid purple !important; border-left: 2px solid purple !important; } blockquote[type=cite] blockquote[type=cite] blockquote[type=cite] blockquote[type=cite] blockquote[type=cite] { border-right: 2px solid green !important; border-left: 2px solid green !important; } moonhkt wrote: Hi All

    How to get current directory path ?

    e.g c:\temp

    how to using perl get current directory path ? "c:\temp"
    Have you tried http://perldoc.perl.org/Cwd.html ? It's a wonderfully enlightening site. I suggest in the future you use it to answer such simple questions.


    --
    Andrew DeFaria
    Doesn't "expecting the unexpected" make the unexpected the expected.
     
    Andrew DeFaria, Sep 1, 2009
    #3
  4. moonhkt <> wrote:
    >How to get current directory path ?
    >
    >e.g c:\temp


    perldoc Cwd

    I think it's a standard module, but I may be wrong.

    jue
     
    Jürgen Exner, Sep 1, 2009
    #4
  5. >>>>> "Jürgen" == Jürgen Exner <> writes:

    Jürgen> perldoc Cwd

    Jürgen> I think it's a standard module, but I may be wrong.

    Yes, been standard for a long time. A *long* time. Perl 5.0, I think.

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <> <URL:http://www.stonehenge.com/merlyn/>
    Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
    See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
     
    Randal L. Schwartz, Sep 1, 2009
    #5
  6. moonhkt

    Justin C Guest

    On 2009-09-01, moonhkt <> wrote:
    > Hi All
    >
    > How to get current directory path ?
    >
    > e.g c:\temp
    >
    > how to using perl get current directory path ? "c:\temp"


    The Current Working Directory?...

    perldoc Cwd
     
    Justin C, Sep 1, 2009
    #6
  7. moonhkt

    Guest

    On Tue, 1 Sep 2009 07:32:49 -0700 (PDT), moonhkt <> wrote:

    >Hi All
    >
    >How to get current directory path ?
    >
    >e.g c:\temp
    >
    >how to using perl get current directory path ? "c:\temp"
    >
    >
    >moonhkt


    use strict;
    use warnings;
    use Cwd;
    use File::Spec::Functions ':ALL';

    my $path = lc rel2abs('c:\\temp\\');

    print "Are we in this direcoty?\n\t$path\n";

    if (chdir($path) and lc rel2abs(cwd()) eq $path) {
    print "Yes indeed, the current directory is:\n\t$path\n";
    } else {
    print "Nope, doesen't appear so..\n";
    }

    -sln
     
    , Sep 1, 2009
    #7
    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. PHaroZ
    Replies:
    5
    Views:
    95,401
    akash02sap
    Aug 17, 2012
  2. Olav Tollefsen

    How to get directory path of current rquest?

    Olav Tollefsen, Oct 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,234
    Scott Mitchell [MVP]
    Oct 29, 2004
  3. Tomek
    Replies:
    2
    Views:
    84,912
    Sandip Chitale
    Oct 2, 2003
  4. Matt
    Replies:
    1
    Views:
    27,462
    Sudsy
    Jun 6, 2004
  5. Rodrigue Butaye

    get the path to the directory of the current user

    Rodrigue Butaye, Aug 15, 2003, in forum: Javascript
    Replies:
    0
    Views:
    126
    Rodrigue Butaye
    Aug 15, 2003
Loading...

Share This Page