in reply to lib

AFAIK use lib extends your @INC path.
So you can include libraries (modules .pm) by
use lib "path/to/your/modules"; use Module;
It has nothing to do with the path to any files you want to open.
----------------------------------- --the good, the bad and the physi-- -----------------------------------

Replies are listed 'Best First'.
Re: Re: lib
by costas (Scribe) on Apr 11, 2001 at 15:19 UTC
    Okay

    One other thing, I want to open this file (which is in the current directory) but it wont let me unless i type in the full path from root.

    open(INPUTFILE, "<postcode.txt")

    I have to do this

    open(INPUTFILE, "</WEBDEV/cgi-bin/postcode.txt")

    Surely the perl knows to look from the existinf directory (eg ".")
    Re: lib
    by kal (Hermit) on Apr 11, 2001 at 15:47 UTC

      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.

        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