#!/usr/bin/perl use strict; open(STDERR,">>error.log") || die "Couldn't redirect STDERR: $!\n"; print STDERR "This goes to the file.\n"; warn "As does this."; die "And this does, too!\n"; close STDERR; #### open(OLDERR,">&STDERR") || die "Couldn't dup STDERR: $!\n"; open(STDERR,">>error.log") || die "Couldn't redirect STDERR: $!\n"; print STDERR "This goes to the file.\n"; warn "As does this."; open(STDERR,">&OLDERR") || die "Couldn't restore STDERR: $!\n"; warn "This goes to the screen.";