Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Divert STDOUT temporarily

by tybalt89 (Monsignor)
on Apr 27, 2020 at 17:45 UTC ( [id://11116126]=note: print w/replies, xml ) Need Help??


in reply to Divert STDOUT temporarily

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11116125 use warnings; print "one\n"; do { local *STDOUT; open STDOUT, '>', '/dev/null' or die; print "two\n +"; }; print "three\n";

Replies are listed 'Best First'.
Re^2: Divert STDOUT temporarily
by jwkrahn (Abbot) on Apr 27, 2020 at 19:05 UTC
    do { local *STDOUT; open STDOUT, '>', '/dev/null' or die; print "two\n +"; };

    You don't need a do{} block when just a bare block will do:

    { local *STDOUT; open STDOUT, '>', '/dev/null' or die; print "two\n"; +}
Re^2: Divert STDOUT temporarily
by Xilman (Hermit) on Apr 27, 2020 at 19:02 UTC

    Many thanks.

    Initial response is "Doh!"

    Second response: I knew I was becoming senile.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11116126]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-24 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found