#use v5.10; #use feature "switch"; use experimental "switch"; use strict; use warnings; # Redirect STDERR open my $fh, '>', 'error.log'; *STDERR = $fh; my $i = 3; given($i) { print "$i\n" when $i < 4; } # Prove STDERR is redirected with runtime error my $error = 10 / 0;