in reply to Re: lib
in thread lib

Seems like a lot of trouble to go to - opening a new shell just to get the current directory. Particularly when Perl has a standard module to do just that.

use Cwd; print cwd;
--
<http://www.dave.org.uk>

"Perl makes the fun jobs fun
and the boring jobs bearable" - me

Replies are listed 'Best First'.
Re: Re: Re: lib
by arhuman (Vicar) on Apr 11, 2001 at 16:12 UTC
    Or even a prefined var ;-)
    print $ENV{'PWD'};

    "Only Bad Coders Badly Code In Perl" (OBC2IP)

      I think that might give you problems on non-Unix platforms.

      --
      <http://www.dave.org.uk>

      "Perl makes the fun jobs fun
      and the boring jobs bearable" - me

        It can also be inaccurate on Unix platforms, because it's a function of some shells, not every shell, and certainly not updated on chdir(2).

        -- Randal L. Schwartz, Perl hacker

      You are both are right, this not a portable way.

      But I DID test it on Both Linux and Windows before submiting, and it worked.
      And as at least one of the other solutions was more platform dependant (`pwd` don't work on windows),
      I've thought it could be an acceptable answer.

      I should have emphasized more about the portability issue, but I was mainly kidding davorg ;-)

      I'll try to be more accurate next time.

      "Only Bad Coders Badly Code In Perl" (OBC2IP)