Same as MVS's answer, but modern and safe.
use strict;
use warnings;
open (my $file, '>', 'output.txt') or die "Could not open file: $!";
my $output = `example.exe`;
die "$!" if $?;
print $file $output;
easier
use strict;
use warnings;
use autodie;
open (my $file, '>', 'output.txt');
print $file `example.exe`;
if you need both STDOUT and STDERR
use strict;
use warnings;
use autodie;
use Capture::Tiny 'capture_merged';
open (my $file, '>', 'output.txt');
print $file capture_merged { system('example.exe') };
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…