my $shell = $ENV{SHELL} || '/bin/sh'; # or maybe get user's shell from /etc/passwd my $home = whatever ... my $envstr = qx($shell -c '. $home/.profile; env'); # some error checking should go on here my %NEWENV = map { split /=/, $_, 2 } split /\n/, $envstr;