0

How do I provide @INC externally for the cover script that is part of the Devel::Cover module. I want cover script to run by searching for libraries relative to where it is triggered.

Idea is to have cover as part of source, and whoever gets this should be able to run directly without concerning the libraries, which will be relative to where it is.

I tried to change the script and have a BEGIN block inside this which will push paths to INC. It works fine, but changing a script is not so good. I want INC to have my relative paths when it is called.

Miller
  • 34,962
  • 4
  • 39
  • 60
Girish
  • 45
  • 5
  • 2
    Env var `PERL5LIB` gets pushed onto `@INC`. There's also `-I`. – ikegami Aug 11 '14 at 17:47
  • That should really be an answer, not a comment... – Len Jaffe Aug 11 '14 at 18:40
  • Can you provide an example for this. -I option is for perl and cover is separate script which when -I is given, it fails or help appears. Sorry, i am new to perl, i need an example. – Girish Aug 12 '14 at 03:27

1 Answers1

0

I would say there are 2 ways:

1-st In the actual script use:

use lib '/home/foobar/code';

2-nd When you are calling the script do -I on the command line (That's a capital i)

The last solution is the most temporary solution. Add a -I /home/foobar/code flag to perl when running the script.

perl -I /home/foobar/code script.pl

This will add /home/foobar/code to the beginning of @INC for this specific execution of the script.

Wald
  • 1,063
  • 7
  • 13