use strict; use warnings; if($^O =~ /mswin32/i){ system(qq!set test=hello && cmd /c "echo %test%"!); }else{ system("test=hello; export test; echo \$test"); }