Skip to content

Instantly share code, notes, and snippets.

@riywo
Created March 21, 2011 22:52
Show Gist options
  • Save riywo/880393 to your computer and use it in GitHub Desktop.
Save riywo/880393 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use IPC::Open2 qw(open2);
## warning = Name "main::OUT1" used only once: possible typo
open2(\*OUT1, undef, 'iostat', '1', '3');
open2(\*OUT2, "<&OUT1", 'cat', '-nu');
print while(<OUT2>);
## error = open2: close(main::GLOB(0x827988)) failed: Bad file descriptor
my ($out1, $out2);
open2($out1, undef, 'iostat', '1', '3');
open2($out2, "<&$out1", 'cat', '-nu');
print while(<$out2>);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment