open (CMDFILE,'cmdfile.cmd & SET |' ) or die "Cant run cmd"; while(){ print qq(EnvVar:$_) ## Look for the variables you want values for };