IO::Select::Trap - IO::Select() functionality on Scalar-based Filehandles


IO-Select-Trap documentation  | view source Contained in the IO-Select-Trap distribution.

Index


NAME

Top

IO::Select::Trap - IO::Select() functionality on Scalar-based Filehandles

SYNOPSIS

Top

 use IO::Select::Trap;
 use IO::String;

 my $ios = new IO::String();
 my $sock = new IO::Socket();
 my $rb = new IO::Select::Trap(<{ trap=>'Scalar|String' }>, $ios, $sock);
 my $wb = new IO::Select::Trap(<{ trap=>'Scalar|String' }>, $ios, $sock);
 my ($rready, $wready) = IO::Select::Trap->select($rb, $wb);

DESCRIPTION

Top

IO::Select::Trap is a wrapper for IO::Select which enables use of the IO::Select->select() method on IO::Scalar or IO::String object/filehandles. Other filehandle object types (ie IO::Socket) are passed through to IO::Select for processing. Most of the IO::Select interface is supported.

An IO::String/Scalar object/filehandle is ready for reading when it contains some amount of data. It will always be ready for writing. Also, IO::String/Scalar objects will *never* block.

When calling select(), the trapped objects are evaluated first. If any are found to be ready, the IO::Select->select() is called with a timeout of '0'. Otherwise it is called with the supplied timeout (or undef).

OPTIONS

Top

trap experimental

REGEX that specifies the IO objects to trap.

LIMITATIONS

Top

Currently, the select(), can_read(), etc. methods only support trapped IO::Scalar or IO::String objects. Other trapped objects will probably break the tests that the methods use to determine read/write ability.

The is a bug when using IO::Scalar objects, in that two IO::Scalars can't be compared. Eg:

  $ios = new IO::Scalar;
  $ios2 = $ios;

  if ($ios == $ios2) { #...

.. causes a runtime error. A fix has been sent to to the author, and should be included in a future version.

AUTHOR & COPYRIGHT

Top

SEE ALSO

Top

IO::Select.


IO-Select-Trap documentation  | view source Contained in the IO-Select-Trap distribution.