Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re^2: Problem running IPTraf from Perl

by RobPayne (Chaplain)
on Jun 17, 2006 at 12:20 UTC ( #555956=note: print w/replies, xml ) Need Help??

in reply to Re: Problem running IPTraf from Perl
in thread Problem running IPTraf from Perl

The idea of not changing global variables is a good thought, but, changing $ENV within a perl script does not effect the shell that the script was run from, you can see that by doing:
$ echo $TERM; perl -e '$ENV{$TERM} = "strange";'; echo $TERM
This holds true whether you edit the (any) variable from Perl or from another (sub-)shell.

Replies are listed 'Best First'.
Re^3: Problem running IPTraf from Perl
by rblasch (Monk) on Jun 17, 2006 at 12:55 UTC

    True, the environment only propagates down the process tree. But any process spawned by the script will see the changed environment, and these changes might be unexpected by other parts of the program. TERM might not be a problem, but others like PATH, LD_PRELOAD, or something else might well be.

    I like to make global changes, not only the environment but every global perl variable, as local as possible.

    print `echo %TERM%`; $ENV{TERM} = 'vt220'; # In some code, far, far away... print `echo %TERM%`;
    C:\tmp>perl %TERM% vt220

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://555956]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2017-11-22 23:16 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (327 votes). Check out past polls.