Puma
|
|
Puma::Util::Buffer
Captures STDOUT into a Perl scalar variable for any evaluated chunk of
code.
use Puma::Util::Buffer; my $foo = new Puma::Util::Buffer; $foo->startCapture; print 'This example uses startCapture and endCapture'; my $footext = $foo->endCapture(); print "footext =\n\t$footext\n\n"; my $bar = new Puma::Util::Buffer; my $bartext = $bar->capture( sub { print "This example uses the 'capture' method"; } ); print "bartext =\n\t$bartext\n\n";
The above example shows the two ways that output can be captured.
The first uses the startCapture() and endCapture() methods to capture the
output of all the code executed between the two methods.
The second portion of the example uses the capture() method to capture
the output of a subroutine reference passed to it.
|