perly_newbie has asked for the wisdom of the Perl Monks concerning the following question:

Hi, From my main perl file I am calling another perl file which has many print commands. I would like to disable these prints without having to go into the called file and delete the print commands. This is bothersome since I call the file with in a loop and the print outputs clutter my cmd line. Is there a way to disable printing for some time so that eventhough the print function is called I dont see the output out on the screen.

Replies are listed 'Best First'.
Re: Disable Print Function for some time
by Marshall (Canon) on Feb 08, 2010 at 05:06 UTC
    Sounds like you are launching scripts with shell as opposed to calling a module function. The easy way to redirect STDOUT to the NULL device when you launch the other program. prog.pl >NUL (on Windows). On Unix this is /dev/null and on Windows this is just NUL. NUL is a Windows reserved "file name" that just goes to the bit bucket. Of course you could use some other file name than NUL and that way you would have a file with the output in it if you wanted to look at it for some reason.
Re: Disable Print Function for some time
by Anonymous Monk on Feb 08, 2010 at 04:38 UTC
    select a different filehandle, or close STDOUT, or write a function that takes a filehandle as argument, and prints to that filehandle instead of the default handle.