/usr/share/perl5/experimental.pm is in libexperimental-perl 0.006-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | package experimental;
$experimental::VERSION = '0.006';
use strict;
use warnings;
use feature ();
use Carp qw/croak carp/;
my %warnings = map { $_ => 1 } grep { /^experimental::/ } keys %warnings::Offsets;
my %features = map { $_ => 1 } keys %feature::feature;
my %grandfathered = (
autoderef => 5.014000,
smartmatch => 5.010001,
lexical_topic => 5.010000,
array_base => 5,
);
my %additional = (
postderef => ['postderef_qq'],
switch => ['smartmatch'],
);
sub _enable {
my $pragma = shift;
if ($warnings{"experimental::$pragma"}) {
warnings->unimport("experimental::$pragma");
feature->import($pragma) if exists $features{$pragma};
_enable(@{ $additional{$pragma} }) if $additional{$pragma};
}
elsif ($features{$pragma}) {
feature->import($pragma);
_enable(@{ $additional{$pragma} }) if $additional{$pragma};
}
elsif (not $grandfathered{$pragma}) {
croak "Can't enable unknown feature $pragma";
}
elsif ($grandfathered{$pragma} > $]) {
croak "Need perl $grandfathered{$pragma} for feature $pragma";
}
}
sub import {
my ($self, @pragmas) = @_;
for my $pragma (@pragmas) {
_enable($pragma);
}
return;
}
sub _disable {
my $pragma = shift;
if ($warnings{"experimental::$pragma"}) {
warnings->import("experimental::$pragma");
feature->unimport($pragma) if exists $features{$pragma};
_disable(@{ $additional{$pragma} }) if $additional{$pragma};
}
elsif ($features{$pragma}) {
feature->unimport($pragma);
_disable(@{ $additional{$pragma} }) if $additional{$pragma};
}
elsif (not $grandfathered{$pragma}) {
carp "Can't disable unknown feature $pragma, ignoring";
}
}
sub unimport {
my ($self, @pragmas) = @_;
for my $pragma (@pragmas) {
_disable($pragma);
}
return;
}
1;
#ABSTRACT: Experimental features made easy
__END__
=pod
=encoding UTF-8
=head1 NAME
experimental - Experimental features made easy
=head1 VERSION
version 0.006
=head1 DESCRIPTION
This pragma provides an easy and convenient way to enable or disable experimental features.
=head2 Disclaimer
Because of the nature of the features it enables, forward compatibility can not be guaranteed in any way.
=head2 Use cases
=over 4
=item * smartmatch
This is effectively equivalent to
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
Except that on versions that do no support smartmatch, it will give an explicit error.
=item * lexical_subs
This is equivalent to
use feature 'lexical_subs';
no warnings 'experimental::lexical_subs';
=back
=head1 SYNOPSYS
use experimental 'lexical_subs', 'smartmatch';
my sub foo { $_[0] ~~ 1 }
=head1 AUTHOR
Leon Timmermans <leont@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|