books
Free Books / Computers / Practical mod_perl /

previous page: 6.4.3. Global Variable Persistence
  
page up: Practical mod_perl | by Stas Bekman and Eric Cholet
  
next page: 6.4.5. Redirecting STDOUT into a Scalar Variable

6.4.4. STDIN, STDOUT, and STDERR Streams




Description

This section is from the "Practical mod_perl" book, by Stas Bekman and Eric Cholet. Also available from Amazon: Practical mod_perl

Under mod_perl, both STDIN and STDOUT are tied to the socket from which the request originated. If, for example, you use a third-party module that prints some output to STDOUT when it shouldn't (for example, control messages) and you want to avoid this, you must temporarily redirect STDOUT to /dev/null. You will then have to restore STDOUT to the original handle when you want to send a response to the client. The following code demonstrates a possible implementation of this workaround:

{
    my $nullfh = Apache::gensym( );
    open $nullfh, '>/dev/null' or die "Can't open /dev/null: $!";
    local *STDOUT = $nullfh;
    call_something_thats_way_too_verbose( );
    close $nullfh;
}

The code defines a block in which the STDOUT stream is localized to print to /dev/null. When control passes out of this block, STDOUT gets restored to the previous value.

STDERR is tied to a file defined by the ErrorLog directive. When native syslog support is enabled, the STDERRstream will be redirected to /dev/null.

 

Continue to:

  • prev: 6.4.3. Global Variable Persistence
  • Table of Contents
  • next: 6.4.5. Redirecting STDOUT into a Scalar Variable

Books by Stas Bekman:















TOP
previous page: 6.4.3. Global Variable Persistence
  
page up: Practical mod_perl | by Stas Bekman and Eric Cholet
  
next page: 6.4.5. Redirecting STDOUT into a Scalar Variable

Topics

  • Animals
  • Architecture
  • Arts
  • Business
  • Computers
  • Crafts
  • Fairy Tales
  • Finance
  • Flora and Plants
  • Cooking
  • Gardening
  • Health and Healing
  • History
  • Home Improvements
  • Languages
  • New Age
  • Novels
  • Real Estate
  • Reference
  • Religion
  • Science
  • Society
  • Sports
  • Travel
  • Outdoors


Search

My Books

Headaches Begone! A Systemic Approach To Healing Your Headaches
Don't Let Your Bike Seat Ruin Your Sex Life Book

Discover

  • Answers FAQ

[ Privacy Policy | Terms of Use | About Us | Search ]

© 2007-2021 StasoSphere.com