Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: invocation mode - how discover?

by Eimi Metamorphoumai (Deacon)
on Dec 10, 2005 at 19:56 UTC ( [id://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 (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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-24 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found