in reply to Re: Nested redirect for STDERR to a string buffer within a perl program
in thread Nested redirect for STDERR to a string buffer within a perl program

Than you tybalt89,
How about using 'local'? .. Is this doing what you want?

Your code works, too.

So, now I have to choose which one to use. :-)

  • Comment on Re^2: Nested redirect for STDERR to a string buffer within a perl program

Replies are listed 'Best First'.
Re^3: Nested redirect for STDERR to a string buffer within a perl program
by NERDVANA (Priest) on May 02, 2025 at 00:08 UTC
    IIRC Capture::Tiny uses a real temp file, so the file handle is redirected even if you fork or exec. If that's something you want to capture, then you need that method. The 'local' to a scalar will only apply to perl code within the same process, but it will also be more efficient because an OS file handle isn't involved.