given and when were introduced back in Perl v5.10 I believe. But they have not been deprecated...I know deprecation of an accepted feature is very, very rare in Perl but these are marked as experimental. I've been looking at them more for curiosity than any need to use them.
Even with use experimental "switch"; they give a warning. I wasn't sure if this was on STDOUT or STDERR so I redirected STDERR and found that the warnings are not on there! I thought that use feature ... gave the warnings and use experimental ... didn't but in both cases I am getting the warnings. So, presumably, use warnings; overrides the experimental part.
#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;
Given that deprecation is so very rare, is it safe to suppress the warnings and use some of the experimental features?