Skip to content

Instantly share code, notes, and snippets.

@jrockway
Created June 13, 2009 19:52
Show Gist options
  • Save jrockway/129407 to your computer and use it in GitHub Desktop.
Save jrockway/129407 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':5.10';
open my $fh, '>', 'test.txt' or die $!;
my $reopen = sub() {
open $_[0], $_[1]. '&='. fileno($_[2]) or die "failed to reopen: $!";
};
$reopen->(*STDOUT, '>', $fh);
system 'date';
print "This also goes to the file.\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment