Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Read a perl's -I flag from perl?

by petr999 (Acolyte)
on Dec 15, 2012 at 09:00 UTC ( [id://1008950]=perlquestion: print w/replies, xml ) Need Help??

petr999 has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

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.

Replies are listed 'Best First'.
Re: Know a perl's -I flag from perl?
by tobyink (Canon) on Dec 15, 2012 at 11:10 UTC

    Devel::PL_origargv

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

      Hello,

      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

      Hello,

      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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2025-06-20 19:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.