sub my_function { local *STDOUT; open STDOUT , "> my_file"; my $proc; Win32::Process::Create($proc , 'c:\windows\system32\cmd.exe' , '/c dir' , 1 , 0, "."); }