diff --git a/Build.PL b/Build.PL index 0b5d1eb..dc50690 100644 --- a/Build.PL +++ b/Build.PL @@ -47,7 +47,7 @@ my $builder = MyBuild->new( 'Digest::MD5' => '2.36', 'Object::ID' => '0.1.0', "Devel::Declare::MethodInstaller::Simple" => '0.006000', - 'true' => '0.12', + 'true::VERSION' => '0.16', 'Capture::Tiny' => '0.06', }, build_requires => { diff --git a/Changes b/Changes index df834f5..3a208d8 100644 --- a/Changes +++ b/Changes @@ -1,16 +1,19 @@ 2.6.0 - New Feature + New Features * Added capture(), from Capture::Tiny, to capture output to STDOUT and STDERR [github 178] Windows Fixes * Fix t/center.t (Myf White) - * Fix t/command_line_wrapper.t + * Fix t/command_line_wrapper.t (Myf White) New Docs * Added perl5ifaq entries for capturing output from a command using capture() + Misc + * The dependency on true.pm will no longer confuse some YAML parsers. + 2.5.1 Fri, 28 Jan 2011 11:01:33 +1000 Misc diff --git a/META.yml b/META.yml index d56730d..e15299a 100644 --- a/META.yml +++ b/META.yml @@ -10,7 +10,7 @@ build_requires: Test::Warn: 0.11 configure_requires: Module::Build: 0.36 -generated_by: 'Module::Build version 0.3623' +generated_by: 'Module::Build version 0.3624' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -134,6 +134,7 @@ provides: version: v2.5.1 requires: CLASS: 1.00 + Capture::Tiny: 0.06 Child: 0.007 DateTime: 0.47 DateTime::Format::Epoch: 0.11 @@ -164,7 +165,7 @@ requires: indirect: 0.22 parent: 0.221 perl: v5.10.0 - 'true': 0.12 + true::VERSION: 0.16 version: 0.77 resources: Chat: irc://irc.perl.org/#perl5i diff --git a/README b/README index 9d93508..57d8dac 100644 --- a/README +++ b/README @@ -652,6 +652,44 @@ What it does encoding turned on. Consequently, if you want to output raw bytes to a file, such as outputting an image, you must set "binmode $fh". + capture() + my($stdout, $stderr) = capture { ... } %options; + my $stdout = capture { ... } %options; + + "capture()" lets you capture all output to "STDOUT" and "STDERR" in any + block of code. + + # $out = "Hello" + # $err = "Bye" + my($out, $err) = capture { + print "Hello"; + print STDERR "Bye"; + }; + + If called in scalar context, it will only return "STDOUT" and silence + "STDERR". + + # $out = "Hello" + my $out = capture { + print "Hello"; + warn "oh god"; + }; + + "capture" takes some options. + + tee tee will cause output to be captured yet still printed. + + my $out = capture { print "Hi" } tee => 1; + + merge + merge will merge "STDOUT" and "STDERR" into one variable. + + # $out = "HiBye" + my $out = capture { + print "Hi"; + print STDERR "Bye"; + } merge => 1; + Carp "croak" and "carp" from Carp are always available.