Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Local library for module test script (updated FindBin)

by LanX (Saint)
on Dec 03, 2014 at 03:55 UTC ( [id://1109069]=note: print w/replies, xml ) Need Help??


in reply to Local library for module test script

use lib ".";

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

update

see FindBin, it's core.

use FindBin qw($Bin); use lib "$Bin";

or

use FindBin qw($Bin); require $Bin.'/lib.pm';

Replies are listed 'Best First'.
Re^2: Local library for module test script
by Anonymous Monk on Dec 03, 2014 at 03:59 UTC
    LanX :) a relative path is relative, with cwd() usually being dist-name-version, and the "module.pm" living in dist-name-version/t/ adding "." wouldn't change anything , require lib.pm would still fail
      Anonymous Monk, I tested  use lib '.'!

      (at least I thought :)

      I supposed that lib takes the file's path as base.

      The perldoc wasn't clear¹, so I tested by changing the working directory with chdir before use and it seemed to work fine.

      But now I am realizing that I should have put the chdir into a BEGIN block, otherwise it happens too late.

      So your point is valid!!!

      Cheers Rolf

      (addicted to the Perl Programming Language and ☆☆☆☆ :)

      ¹) but led me now to FindBin

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1109069]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-25 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found