Variables de entorno

El hash %ENV contiene las variables de entorno. Su modificación implica la modificación del entorno del programa.
$ENV{PATH} = $ENV{PATH}:"/home/casiano/bin";
delete $ENV{DISPLAY};
system 'myls';
En este ejemplo el program myls es ejecutado en un entorno en el cual el PATH incluye a /home/casiano/bin y la variable DISPLAY ha sido suprimida.

Ejercicio 1.3.1   En Perlmonks apareció la siguiente pregunta (puede encontrarla buscando en http://www.perlmonks.org/ por 'Environmental Settings'.
I require some assistance. I am writing a CGI script in Perl on Solaris
that needs to run external commands using the 'system' operator. These
commands are part of a larger package that needs the system initialized
(via a command) properly before execution, or else each individual
command cannot interact with the other, like the following.

1: system "/PATH/initialize_system"; # init the environment
2: system "/PATH/skew.k ARG_FOR_FRAME_NUMBER"; # create image
3: system "/PATH/savegif.k FRAME_NUMBER"; # save image off
4: system "exit"; # exit the environment created with initialize_system

When running a command using 'system', the environment appears to only
lasts until the next line of Perl code, so line 2 can't talk to line
3 because the environment required for them to communicate isn't there
which is initialized by line 1. The above code snippet would the way it
is run from a command line. 

Any help would be appreciated. 
Thanks.

¿Cuál es su respuesta?

Ejercicio 1.3.2   Ejecute los comandos:
$ set | grep "^[A-Z]" |wc
$ perl -e 'print "$_ = $ENV{$_}\n" for sort keys %ENV;' | wc
¿A que se debe la diferencia?. Consulte el módulo Env::Bash . Discuta su funcionalidad.

Casiano Rodríguez León
2010-03-22