#!/usr/bin/perl use warnings; use strict; my $log; open my $logOut, '>', \$log; my $oldStdOut = select $logOut; print "this goes to the log string\n"; select $oldStdOut; close $logOut; print "From log: $log"; #### From log: this goes to the log string