Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (14)
As of 2016-10-26 11:09 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (340 votes). Check out past polls.