NAME
IO::Util - Captures the output sent to a file handler
VERSION 1.0
SYNOPSIS
use IO::Util qw(capture);
# captures the selected file handler
$output_ref = capture { some_printing_code } ;
# captures FILEHANDLER
$output_ref = capture { some_printing_code } FILEHEANDLER ;
sub some_printing_code {
print 'something'
}
DESCRIPTION
This is a micro-weight module that exports just the capture
function. It executes the code inside the first argument block, and captures the output it sends to the selected file handler (or to a specific file handler). It "hijacks" all the write
and print
statements addressed to the captured filehandler, returning the scalar reference of the output. Sort of "print to scalar" function.
INSTALLATION
- CPAN
-
perl -MCPAN -e 'install IO::Util'
- Standard installation
-
From the directory where this file is located, type:
perl Makefile.PL make make test make install
FUNCTIONS
capture { code } [ FILEHANDLER ]
The capture
function espects a code block as the first argument and an optional FILEHANDLER as the second argument. If FILEHANDLER is omitted the selected file handler will be used by default (usually STDOUT
). The function returns the reference to the captured output.
SUPPORT and FEEDBACK
If you need support or if you want just to send me some feedback or request, please use this link: http://perl.4pro.net/?IO::Util.
AUTHOR and COPYRIGHT
© 2004 by Domizio Demichelis.
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 90:
Non-ASCII character seen before =encoding in '©'. Assuming CP1252