In Perl I use standard commands for printing:
print "text"; # STDOUT
print STDOUT "text";
print STDERR "text";
How can I dynamically change redirection of STDOUT
and STDERR
to different files?
Let's say I have a simple loop with $i
going from $min
to $max
and I want to dynamically change redirections to files "out_$n"
and "err_$n"
files where $n = int($i/1000)
.
I don't want to change my existing print
commands, so I am looking for solution that would just add this redirection functionality without changing of existing code.
Just reopen STDOUT
open(STDOUT, '>', $qfn)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With