I'm afraid I don't know what you mean with "STDOUT path = 'c:/users/outputs/out.txt';". But I can answer the general question about how to capture a script's STDOUT from within that script. First, and this has the most limited general usefulness, you can use select to change the default output handle for print statements.
But probably most useful is Capture::Tiny, which can capture output not only from the Perl script itself but any external processes it happens to run. Its documentation includes a list of other output-capturing modules, such as ones that use another method for capturing output to a filehandle, tied handles. But I wouldn't necessarily recommend that method either, since it is also not generally applicable (e.g. it won't capture things from external programs run). Update: For the sake of completeness, as another method, the open documentation shows how to re-open STDOUT, but this is a fairly low-level operation and again I'd recommend the help of a module here. In any of the aforementioned cases you can of course save the name of the target file in a variable, or perhaps get it from an environment variable via %ENV or the command line via e.g. @ARGV or Getopt::Long.
In reply to Re: Redirecting Standard Output inside perl
by haukex
in thread Redirecting Standard Output inside perl
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |