Joel Berger > Tie-Select-0.01 > Tie::Select

Download:
Tie-Select-0.01.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Tie::Select - Provides a localized interface to the select function

SYNOPSIS ^

 use strict; use warnings;
 use Tie::Select;

 {
   local $SELECT = *STDERR;
   print "This goes to STDERR";
 }

 print "This goes to STDOUT";

DESCRIPTION ^

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.

 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.

The inspiration for this type of interface is File::chdir which provides a similar localizable interface to the current working directory.

SEE ALSO ^

SOURCE REPOSITORY ^

http://github.com/jberger/Tie-Select

AUTHOR ^

Joel Berger, <joel.a.berger@gmail.com>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: