Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Read a perl's -I flag from perl?

by petr999 (Acolyte)
on Dec 15, 2012 at 09:00 UTC ( #1008950=perlquestion: print w/ replies, xml ) Need Help??
petr999 has asked for the wisdom of the Perl Monks concerning the following question:


I run a perl binary with a perl interpreter from my perl program with system.

Both perl binary I run with system and my perl program that runs it require the library (module) for inclusion. The 'parent' perl source gets it with perl's -I flag. I assume it is always 'all right' and my module is always found.

What I want is to pass that -I flag to the 'child' program as it is/they are specified for the 'parent' program.

I think to formulate this task as 'to get all of the flags supplied for the current Perl interpreter' should be okay as I can get the matching qr{^-I} flags then.

The problem is: how can I get my Perl's interpreter's runtime flags? perlvar was no much help to me. Where should this info be found?

In details, I'd like to test my bin/stuff run from my t/555-test.t. By far the test will be supplied the '-I' flags from both 'prove' and 'make test' as well as need no the '-I' flags after being installed so I'd like to have my '-I' flag for my Perl interpreter to run it in the system() exactly the same as for my test being performed.

Can this be done?

Thank you.

Comment on Read a perl's -I flag from perl?
Select or Download Code
Replies are listed 'Best First'.
Re: Know a perl's -I flag from perl?
by tobyink (Abbot) on Dec 15, 2012 at 11:10 UTC


    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


      Pleased! Thanks! will try.

      Thank you.

Re: Know a perl's -I flag from perl?
by Anonymous Monk on Dec 15, 2012 at 10:45 UTC


      You are very right Anoymous.

      And I can accept the point of view that perl interpreter flags should not be controlled from perl source.

      Actually I can imagine that there can be another kind of perl interpreter that can have the different flags an/or not to be a binary at all (e. g., a binary library) and it may not accept namely the -I flag.

      But I think the task is quite straightforward to take those condireations not as seriously as I can.

      It's all just about to run the binary from make test or prove.

      I believe it's not a problem for you to suggest another way to supply the libraries path for perl binary to run from tests, if you have any.

      Thank you.

        The purpose of -I is to populate @INC

        You don't need the original -I flags, you have @INC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1008950]
Approved by McDarren
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2016-05-27 23:02 GMT
Find Nodes?
    Voting Booth?