my $fh = File::Temp->new(); $fh->autoflush(1); foreach my $cmd (@_) { print "$cmd\n"; print $fh "$cmd\n"; } system "dir $fh";