5 $unicode8bit::hint_bits = 0x00000800;
8 "5.10" => [qw(unicode8bit)],
9 "5.11" => [qw(unicode8bit)],
12 my %legacy = ( 'unicode8bit' => '0' );
16 legacy - Perl pragma to preserve legacy behaviors or enable new non-default
21 use legacy ':5.10'; # Keeps semantics the same as in perl 5.10
27 #no legacy qw(unicode8bit);
33 Some programs may rely on behaviors that for others are problematic or
34 even wrong. A new version of Perl may change behaviors from past ones,
35 and when it is viewed that the old way of doing things may be required
36 to still be supported, that behavior will be added to the list recognized
37 by this pragma to allow that.
39 Additionally, a new behavior may be supported in a new version of Perl, but
40 for whatever reason the default remains the old one. This pragma can enable
43 Like other pragmas (C<use feature>, for example), C<use legacy qw(foo)> will
44 only make the legacy behavior for "foo" available from that point to the end of
47 B<This pragma is, for the moment, a skeleton and does not actually affect any
52 Preserve the old way of doing things when a new version of Perl is
53 released that changes things
57 Turn on a new behavior in a version of Perl that understands
58 it but has it turned off by default. For example, C<no legacy 'foo'> turns on
59 behavior C<foo> in the lexical scope of the pragma. Simply C<no legacy>
60 turns on all new behaviors known to the pragma.
64 It's possible to turn off all new behaviors past a given release by
65 using a I<legacy bundle>, which is the name of the release prefixed with
66 a colon, to distinguish it from an individual legacy behavior.
68 Specifying sub-versions such as the C<0> in C<5.10.0> in legacy bundles has
69 no effect: legacy bundles are guaranteed to be the same for all sub-versions.
71 Legacy bundles are not allowed with C<no legacy>
78 croak("No legacy behaviors specified");
82 if (substr($name, 0, 1) eq ":") {
83 my $v = substr($name, 1);
84 if (!exists $legacy_bundle{$v}) {
85 $v =~ s/^([0-9]+)\.([0-9]+).[0-9]+$/$1.$2/;
86 if (!exists $legacy_bundle{$v}) {
87 unknown_legacy_bundle(substr($name, 1));
90 unshift @_, @{$legacy_bundle{$v}};
93 if (!exists $legacy{$name}) {
94 unknown_legacy($name);
96 $^H &= ~$unicode8bit::hint_bits; # The only thing it could be as of yet
104 # A bare C<no legacy> should disable *all* legacy behaviors
106 unshift @_, keys(%legacy);
111 if (substr($name, 0, 1) eq ":") {
112 croak(sprintf('Legacy bundles (%s) are not allowed in "no legacy"',
115 if (!exists($legacy{$name})) {
116 unknown_legacy($name);
119 $^H |= $unicode8bit::hint_bits; # The only thing it could be as of yet
126 croak(sprintf('Legacy "%s" is not supported by Perl %vd', $legacy, $^V));
129 sub unknown_legacy_bundle {
131 croak(sprintf('Legacy bundle "%s" is not supported by Perl %vd',