Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

getting called with interpreter arguments, not script arguments, not @ARGV

by bulk88 (Priest)
on Jul 10, 2013 at 22:28 UTC ( #1043579=perlquestion: print w/ replies, xml ) Need Help??
bulk88 has asked for the wisdom of the Perl Monks concerning the following question:

@ARGV gives you the arguments from the command line that came after the script name. How do you from inside a script get the cmd line arguments that appeared before the script name when the script was executed?

example
perl -MFoo::Module -I./specialib scriptname.pl --argv_arg
scriptname.pl needs to do a system($^X, and pass the same exact -I and -M arguments to the child perl process. The names of modules loaded with the -M are random and not from a fixed list from the viewpoint of scriptname.pl. Looking at @INC and %INC is a problem because of unpredictable PERL5LIB/PERLLIB/PERL5DB/interp compile options.

scriptname.pl is really a Makefile.PL that calls EUMM, and I'm trying to fix a problem in EUMM, where the makefile that EUMM generates determines it is out of date and regenerates itself (it=makefile), that makefile, doesn't call Makefile.PL with the same interp args (-Is and -Ms) that the 1st Makefile.PL run was called with, so the regenerated makefile is very different from the 1st makefile, which then breaks the compiling process.

Comment on getting called with interpreter arguments, not script arguments, not @ARGV
Select or Download Code
Re: getting called with interpreter arguments, not script arguments, not @ARGV
by thomas895 (Hermit) on Jul 10, 2013 at 22:51 UTC

    Why not just set scriptname.pl to executable(if not on Windows), and then pass the additional libs to load on the command line? The same applies to the include dirs.
    For example, consider the following:

    my @modules = split ",", $ARGV[0]; my @paths = split ":", $ARGV[1]; #change to ';' or other on Windows, + if needed push(@INC, @paths); $@ = undef; map { eval("require $_;") unless $@ } @modules; if($@) { die "one or more modules failed: $@"; } #rest of script
    ~Thomas~ 
    "Excuse me for butting in, but I'm interrupt-driven..."
Re: getting called with interpreter arguments, not script arguments, not @ARGV
by BrowserUk (Pope) on Jul 10, 2013 at 22:58 UTC

    On windows you can use GetCommandLine() to obtain the full command line used to invoke perl.exe.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: getting called with interpreter arguments, not script arguments, not @ARGV ( Devel::PL_origargv )
by Anonymous Monk on Jul 10, 2013 at 23:07 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2014-12-25 06:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls