public
Created

SelectSaver vs Tie::Select

  • Download Gist
select_holders.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
use SelectSaver;
use Tie::Select;
 
open my $fh1, '>', \my $var1;
open my $fh2, '>', \my $var2;
 
#Select Saver
 
{
my $sh1 = SelectSaver->new( $fh1 );
print "To var1";
 
# undef $sh1 here fixes this but now we are almost back to select()
 
my $sh2 = SelectSaver->new( $fh2 );
print "To var2";
}
 
print "Goes where?";
 
# Tie::Select
 
{
local $SELECT = $fh1;
print "To var1";
 
$SELECT = $fh2;
print "To var2";
}
 
print "To STDOUT";

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.