Aijaz Ansari > TaskForest > TaskForest::StringHandle

Download:
TaskForest/TaskForest-1.33.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 1.30   Source  

NAME ^

StringHandle - intercept text sent to stdout or stderr

SYNOPSIS ^

 $text1 = "This should go to STDOUT\n";
 $text2 = "This is the second line\n";

 $sh = TaskForest::StringHandle->start(*STDOUT);
                          # stdout is being captured as a string
 print $text1;            # nothing is printed to stdout
 $stdout1 = $sh->read();  # $stdout1 eq $text1
 $stdout2 = $sh->read();  # $stdout2 eq ''
 print $text2;            # nothing is printed now either
 $stdout3 = $sh->stop();  # $stdout3 eq $text2, capture stopped
 print "Hello, world!\n"; # this is printed to stdout

DESCRIPTION ^

This is a simple class that you can use to intercept any text that would have been written to stdout or stderr or any file handle and saves it instead locally. You can then retrieve the text and use it to examine what would have been sent to stdout (or stderr). It was developed primarily to help with the test cases.