#!/usr/bin/env perl -w use strict; my $foo = qx{ ls baz 2>&1 }; open my $fh, '>', 'bar.out' or die $!; print $fh $foo; close $fh; __END__