Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    IO::NestedCapture 1.03

    Download button

    No screenshots available
    Downloads: 422  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Good (3.1/5)
    8 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Andrew Sterling Hanenkamp | More programs
    Perl Artistic License / FREE
    January 13th, 2008, 21:10 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    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 McGonagall

    This 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=459275

    This 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.

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    nested STD | nested capture | Perl module | nested | STD | capture

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM