Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Finding what args were passed to the perl interpretter ?

by oko1 (Deacon)
on Nov 19, 2008 at 23:05 UTC ( #724756=note: print w/replies, xml ) Need Help??


in reply to Finding what args were passed to the perl interpretter ?

Well, you'd have to map the code that gets displayed back to the relevant commandline args, but you could use B::Deparse:

ben@Tyr:~$ perl -MO=Deparse -wle# BEGIN { $^W = 1; } BEGIN { $/ = "\n"; $\ = "\n"; } -e syntax OK

Note that the above 'BEGIN' statements differ from actual 'BEGIN' blocks: those are shown as 'sub BEGIN'.


--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf

Replies are listed 'Best First'.
Re^2: Finding what args were passed to the perl interpretter ?
by dpuu (Chaplain) on Nov 19, 2008 at 23:24 UTC
    Thanks for the reply. Unfortunately, that doesn't seem applicable to the problem I was trying to solve (which I guess I didn't state in my original post): the ultimate goal was for a script to detect that it was being run under -d:NYTProf, and to add that option (and other similar things) to various child perl-scripts that it runs.
    --Dave
    Opinions my own; statements of fact may be in error.
      I don't think there's a general way to get the arguments to perl from with Perl. However, an XS routine may be able to access argv and argc (although I've no idea whether perl itself leaves them as is).

      As for your specific request, detecting -d:NYTProf, it may be done. One of the effects of -d:foo is that it loads Devel::foo, and calls Devel::foo -> import. You may want to try to mask Devel::NYTProf::import.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2023-12-08 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (37 votes). Check out past polls.

    Notices?