Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: Can I do this ???

by BrowserUk (Patriarch)
on Jan 22, 2009 at 15:51 UTC ( [id://738198]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Can I do this ???
in thread Can I do this ???

The reason that works is because there is no child process involved.

The called script is processed by the calling process--in the same fashion as Perl's do script.pl;--and the changes are made to the current process' environment by the current process.

The effect is exactly the same as:

## Called .pl $::ENV{ somekey } = 'somevalue'; ##calling script; do 'called.pl';

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^5: Can I do this ???
by MidLifeXis (Monsignor) on Jan 22, 2009 at 16:02 UTC

    Very true, and I should have made that point clear.

    What I meant to demonstrate is that a "typical" windows batch mode programming style (well, what I saw when I was in an environment where I had to care about those scripts) allows, even encourages, modifying the "parent" process from things that are called.

    --MidLifeXis

        And it's not so different from the *nix shell mechanism of somekey=somevalue command.

        On all Unix shells I know, the caller has influence on whether somekey would end up in his/her environment, not (like in Windows Batch) the callee. For instance, if I call from bash a script like this:

        source gurgle.bash
        no child is born and the environment changes will be reflected in my environment. If I call it like this:
        gurgle.bash
        or
        bash gurgle.bash
        I do get a child and my environment stays unpolluted.

        -- 
        Ronald Fischer <ynnor@mm.st>

Log In?
Username:
Password:

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

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

    No recent polls found