Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^3: invocation mode - how discover?

by Eimi Metamorphoumai (Deacon)
on Dec 10, 2005 at 19:56 UTC ( #515747=note: print w/replies, xml ) Need Help??

in reply to Re^2: invocation mode - how discover?
in thread invocation mode - how discover?

caller is really only useful in a subroutine, to tell you the name of the subroutine that called it. I think I understand what you're asking for, but I don't understand why. The answer is that it's not easy (you'd have to start with getppid and then find the process that corresponds to that pid, then find its command). But in general, it's relatively rare for perl scripts to be called from each other by backticks. It's usually much better practice to factor out the parts that are needed in different places into subroutines. So the big question I have is, "What exactly are you trying to achieve?" It's usually a very bad idea (for debugging if nothing else) to have your program behave differently depending on who calls it. What are your end goals? There's probably a much more perlish way of doing it.

Replies are listed 'Best First'.
Re^4: invocation mode - how discover?
by toolsmith (Initiate) on Dec 15, 2005 at 22:57 UTC
    Sorry. Duty called, kept me away. I am sure you are right that what I'm trying is a mistake. In fact, in perl it's a non-problem even when I'm making the mistake, because backticks automatically redirect stdout into an array. It's just residual rexx limitation workarounds that had me looking for a way to identify exernal caller. But I will play with getppid just for fun. Thanks again - Toolsmith

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2020-10-31 05:27 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (286 votes). Check out past polls.