my ($key, $value); while (($key, $value) = each %ENV) { print "$key = $value\n"; # or do whatever here }