Subject: | [PATCH] Lvalue references |
See attachment.
Subject: | open_UbF5tmGO.txt |
diff --git a/lib/experimental.pm b/lib/experimental.pm
index b91ac7d..2b2cf55 100644
--- a/lib/experimental.pm
+++ b/lib/experimental.pm
@@ -25,6 +25,7 @@ my %min_version = (
fc => '5.16.0',
lexical_topic => '5.10.0',
lexical_subs => '5.18.0',
+ lvalue_refs => '5.21.5',
postderef => '5.20.0',
postderef_qq => '5.20.0',
regex_sets => '5.18.0',
@@ -58,7 +59,13 @@ sub _enable {
croak "Can't enable unknown feature $pragma";
}
elsif ($min_version{$pragma} > $]) {
- croak "Need perl $min_version{$pragma} or later for feature $pragma";
+ my $stable = $min_version{$pragma};
+ if ($stable->{version}[1] % 2) {
+ $stable = version->new(
+ "5.".($stable->{version}[1]+1).'.0'
+ );
+ }
+ croak "Need perl $stable or later for feature $pragma";
}
}
@@ -146,6 +153,7 @@ The supported features, documented further below, are:
array_base - allow the use of $[ to change the starting index of @array
autoderef - allow push, each, keys, and other built-ins on references
lexical_topic - allow the use of lexical $_ via "my $_"
+ lvalue_refs - allow aliasing via \$x = \$y
postderef - allow the use of postfix dereferencing expressions, including
in interpolating strings
regex_sets - allow extended bracketed character classes in regexps
diff --git a/t/basic.t b/t/basic.t
index 239225b..5dc2eaf 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -50,5 +50,14 @@ if ($] >= 5.018) {
END
}
+if ($] >= 5.021005) {
+ is (eval <<'END', 1, 'lvalue ref compiles') or diag $@;
+ use experimental 'lvalue_refs';
+ \@a = \@b;
+ is(\@a, \@b, '@a and @b are the same after \@a=\@b');
+ 1;
+END
+}
+
done_testing;