Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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.

Comment on Re^2: Problem running IPTraf from Perl
Download Code
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 making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2015-11-29 06:17 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (747 votes), past polls