IO::NestedCapture

IO::NestedCapture is a Perl module for performing nested STD* handle captures.
Download

IO::NestedCapture Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Andrew Sterling Hanenkamp
  • Publisher web site:
  • http://search.cpan.org/~hanenkamp/

IO::NestedCapture Tags


IO::NestedCapture Description

IO::NestedCapture is a Perl module for performing nested STD* handle captures. IO::NestedCapture is a Perl module for performing nested STD* handle captures.SYNOPSIS use IO::NestedCapture qw/ :subroutines /; my $in = IO::NestedCapture->get_next_in; print $in "Harryn"; print $in "Ronn"; print $in "Hermionen"; capture_in_out { my @profs = qw( Dumbledore Flitwick McGonagall ); while (< STDIN >) { my $prof = shift @prof; print STDOUT "$_ favors $prof"; } }; my $out = IO::NestedCapture->get_last_out; while (< $out >) { print; } # This program will output: # Harry favors Dumbledore # Ron favors Flitwick # Hermione favors McGonagallThis module was partially inspired by IO::Capture, but is intended for a very different purpose and is not otherwise related to that package. In particular, I have a need for some pretty aggressive output/input redirection in a web project I'm working on. I'd like to be able to pipe input into a subroutine and then capture that subroutines output to be used as input on the next.I was using a fairly clumsy, fragile, and brute force method for doing this. If you're interested, you can take a look at the code on PerlMonks.org: http://perlmonks.org/?node_id=459275This module implements a much saner approach that involves only a single tie per file handle (regardless of what you want to tie it to). It works by tying the STDIN, STDOUT, and STDERR file handles. Then, uses internal tied class logic to handle any nested use or other work.With this module you can capture any combination of STDIN, STDOUT, and STDERR. In the case of STDIN, you may feed any input into capture you want (or even set it to use another file handle). For STDOUT and STDERR you may review the full output of these or prior to capture set a file handle that will receive all the data during the capture.As of version 1.02 of this library, there are two different interfaces to the library. The object-oriented version was first, but the new subroutine interface is a little less verbose and a little safer. Requirements: · Perl


IO::NestedCapture Related Software