Tie::Select - Provides a localized interface to the select function
select
use strict; use warnings; use Tie::Select; { local $SELECT = *STDERR; print "This goes to STDERR"; } print "This goes to STDOUT";
The Perl builtin print, when not called with an explicit file handle, will print to the file handle designated by the select command. This is a global action, which is bad. Further, it has an awkward interface for restoring a previous handle; on a call to select a reference to the old handle is returned, which has to itself be select-ed to restore the old handle. Better to see an example.
print
my $stdin = select *STDERR; print "To STDERR"; select $stdin;
Tie::Select offers a localizable interface to select. Simply assign a handle to the $SELECT variable this module to change the select-ed handle. If this is done with local the change is dynamically bound to the enclosing scope.
$SELECT
local
The inspiration for this type of interface is File::chdir which provides a similar localizable interface to the current working directory.
File::chdir - Allow localized working directory, inspiration for this module
Lexical::select - As the name implies, it provides a lexically scoped interface to the select function rather than dynamically scoped
IO::Select - This time its an Object-Oriented interface to select
http://github.com/jberger/Tie-Select
Joel Berger, <joel.a.berger@gmail.com>
Copyright (C) 2012 by Joel Berger
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Tie::Select, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::Select
CPAN shell
perl -MCPAN -e shell install Tie::Select
For more information on module installation, please visit the detailed CPAN module installation guide.