in reply to Re: Re: lib
in thread lib

If you're running it as a CGI you don't necessarily know what the current directory is. Try doing a print `pwd`; to see where the script actually is.

Usually, with things like file paths, it can be useful to make a configuration variable that holds this stuff in, so when you open you do something more like open (INPUTFILE, "<$root/postcode.txt");. $root can be a variable set at the top of the file, read in from a configuration file, etc.

Replies are listed 'Best First'.
Re: Re: lib
by davorg (Chancellor) on Apr 11, 2001 at 16:10 UTC

    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

      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

        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)