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