Mark Overmeer > IOMux > IOMux::Open

Download:
IOMux-0.12.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.12   Source  

NAME ^

IOMux::Open - simulate the open() function

SYNOPSIS ^

  use IOMux::Open qw( -| |- |-| < > >> tcp);

  # pipe for reading
  my $who = $mux->open('-|', 'who', 'am', 'i');
  print <$who>;

  # two-way connection (like IPC::Open3)
  my $echo = $mux->open('=|', 'cat');

  # file
  my $pw = $mux->open('<', '/etc/passwd');
  my @noshell = grep /\:$/, <$pw>;

DESCRIPTION ^

This module is a simple wrapper to bring various alternative connection implementations closer to normal Perl. It also saves you a lot of explicit require (use) lines of code.

With this module, code is simplified. For instance, the real logic is:

  use IOMux::Pipe::Read;
  my $who = IOMux::Pipe::Read->new
   ( run_shell => [ 'who', 'am', 'i' ]
   );
  $mux->add($who);
  print <$who>;

In the short syntax provided with this module:

  use IOMux::Open '-|';
  my $who = $mux->open('-|', 'who', 'am', 'i');
  print <$who>;

You only need to use one ::Open module with some parameter, in stead of requiring all long names explicitly. As you can see, the object gets added to the mux as well.

METHODS ^

Constructors

IOMux::Open->new(MODE, PARAMS)

Available MODES are

    -|  IOMux::Pipe::Read
   |-   IOMux::Pipe::Write
   |-|  IOMux::IPC
   |=|  IOMux::IPC          (with errors)
    >   IOMux::File::Write
    >>  IOMux::File::Write  (appendinf)
    <   IOMux::File::Read

Accessors

SEE ALSO ^

This module is part of IOMux distribution version 0.12, built on January 27, 2011. Website: http://perl.overmeer.net/ All modules in this suite: "Any::Daemon", "IOMux", and "IOMux::HTTP".

Please post questions or ideas to perl@overmeer.net

LICENSE ^

Copyrights 2011 by Mark Overmeer. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html

syntax highlighting: