in reply to Run system command in same context of the script itself
[When I read "I have a script that runs a set of commands", I thought you meant a shell script that executed the Perl program showed. A more careful re-reading show this is probably not what you meant. This answer probably won't help you.]
There's no generic way of making another process do something.
If the Perl program needs to cause Perl's parent process to do something, you will need devise a way to communicate with it if there isn't already one, and ask it to perform the action using that method of communication. How this should be done will depend on the parent process and what exactly you want to do.
For example, if the parent is expected to be sh, you could have the program output sh commands to stdout and have the shell capture and execute them.
x=123 printf '%s\n' "$x" # 123 eval "$( perl -Mv5.14 -e'say "x=456"' )" printf '%s\n' "$x" # 456
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Run system command in same context of the script itself
by igorle (Initiate) on Apr 10, 2023 at 14:52 UTC | |
by LanX (Saint) on Apr 10, 2023 at 15:03 UTC | |
by ikegami (Patriarch) on Apr 10, 2023 at 16:35 UTC |