in reply to How to use a .pm file in a .pl file in another directory.

I think you need something like this: use lib "path/to/Chess path/to/Chess/Piece";
use lib "path/to/Chess"; use Chess::Piece::Knight; use Chess::Piece;
Oh, geeze this Piece directory as well as Piece.pm looks like trouble to me.

Replies are listed 'Best First'.
Re^2: How to use a .pm file in a .pl file in another directory.
by Eliya (Vicar) on Jan 29, 2012 at 16:40 UTC
    use lib "path/to/Chess path/to/Chess/Piece";

    In this case, when you try to use Chess::Piece, Perl would look for "path/to/Chess path/to/Chess/Piece/Chess/Piece.pm" — so that likely won't work.

    Perl essentially does the following to create the full path:

    use lib "searchpath"; use Chess::Piece; / / .pm => "searchpath/Chess/Piece.pm"