http://www.perlmonks.org?node_id=11124452


in reply to Re^3: Experimental warnings with given/when
in thread Experimental warnings with given/when

Are you sure?

I thought I was but I set up a little test to make sure I was sure and now I am not...

use feature "switch"; # Redirect STDERR open my $err_fh, '>', 'stderr.log'; *STDERR = $err_fh; # Redirect STDERR open my $out_fh, '>', 'stdout.log'; *STDOUT = $out_fh; my $i; given($i) { print "$i\n" when $i < 4; } # Prove STDERR is redirected my $error = 10 / 0;

Illegal division by zero at test.pl line 15. is the only thing that is written to STDERR and 3 gets written to STDOUT but the following still gets displayed on the command prompt:

C:\Users\ian\Perl>perl test.pl given is experimental at test.pl line 10. when is experimental at test.pl line 11. C:\Users\ian\Perl>

So I am not really sure what is going on with output streams as the warnings are on neither STDERR nor STDOUT.

This is using Perl v5.28.1

Replies are listed 'Best First'.
Re^5: Experimental warnings with given/when
by hippo (Bishop) on Dec 01, 2020 at 13:40 UTC
    the following still gets displayed on the command prompt

    Those are compile-time warnings. They are generated before your run-time massaging of STDOUT and STDERR have taken effect. In contrast, I used the calling shell to set up the redirection so it is clear there that these warnings go to STDERR.


    🦛