The %ENV hash contains the environment variables. If you change the value of %ENV, you will alter the environment. #!/usr/bin/perl foreach $key (keys(%ENV){ print "$key\n"; } print "\nYour login name $ENV{'LOGNAME'}\n"; $pwd=$ENV{'PWD'}; print "\n", $pwd, "\n";