Tie::STDOUT

Intercept writes to STDOUT and apply user-defined functions to them
Download

Tie::STDOUT Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • David Cantrell
  • Publisher web site:
  • http://search.cpan.org/~dcantrell/

Tie::STDOUT Tags


Tie::STDOUT Description

Intercept writes to STDOUT and apply user-defined functions to them Tie::STDOUT is a Perl module that intercepts all writes to the STDOUT filehandle and applies whatever function you desire to what would have gone to STDOUT. In the example above, any use of the print() function on this filehandle will have its output transmogrified into upper case.You will have noticed that we blithely print to the default filehandle (which is almost always STDOUT) in the function we supplied. Relax, this doesn't cause an infinite loop, because your functions are always called with a *normal* STDOUT.You may provide up to three user-defined functions which are respectively called whenever you use print(), printf() or syswrite() on the filehandle:print defaults to printing to the real STDOUT;printf defaults to passing all parameters through sprintf() and then passing them to whatever the 'print' function is;syswrite Defaults to going straight through to the real STDOUT.You will note that the default behaviour is exactly the same as it would be without this module.Because we have a sensible default for 'printf' and because syswrite is so rarely used, you will normally only have to provide your own code for 'print'.SYNOPSIS use Tie::STDOUT print => sub { print map { uc } @_; }, printf => ... syswrite => ... ; Requirements: · Perl


Tie::STDOUT Related Software