script to find the current directory

Discussion in 'Perl Misc' started by Kannan Ekanath, Jan 30, 2004.

  1. Hi,
    stuck up with this real sitter. can someone tell me how to find the full
    path of the current directory inside a pearl script (because the script
    can be called from different directories i just wanted to know the full
    path of the directory i.e, the caller).

    saw things like
    my @filelist = global("*");
    to get the file list...is there any way to get the current directory
    Right now i am using the alternative of pwd >> somefile and picking it
    up from there

    Thanks
    Kannan
    Kannan Ekanath, Jan 30, 2004
    #1
    1. Advertising

  2. Kannan Ekanath wrote:

    > can someone tell me how to find the full path of the current directory


    Here are two ways:

    use Cwd; # more portable
    my $dir = cwd;

    or

    my $dir = `pwd`; # assuming unix-like os here
    chomp $dir;

    --
    Todd de Gruyl
    Todd de Gruyl, Jan 30, 2004
    #2
    1. Advertising

  3. Kannan Ekanath wrote:
    > stuck up with this real sitter. can someone tell me how to find the
    > full path of the current directory [...]


    perldoc Cwd

    jue
    Jürgen Exner, Jan 30, 2004
    #3
    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. Prashant
    Replies:
    2
    Views:
    328
    Nick Stinemates
    Apr 18, 2008
  2. Wybo Dekker
    Replies:
    1
    Views:
    330
    Yukihiro Matsumoto
    Nov 15, 2005
  3. laredotornado
    Replies:
    5
    Views:
    106
    Brian Candler
    Jan 2, 2010
  4. Replies:
    4
    Views:
    173
    Josef Moellers
    Oct 27, 2007
  5. andipfaff
    Replies:
    6
    Views:
    159
    andipfaff
    May 13, 2008
Loading...

Share This Page