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.
Re^4: invocation mode - how discover?
by toolsmith (Novice) 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 | [reply] |
|