print STDOUT "hey1"; { local *STDOUT; open( STDOUT , ">test" ); print STDOUT "hey2"; } print STDOUT "hey3";