summaryrefslogtreecommitdiff
path: root/pod/perlsub.pod
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-04-24 16:29:42 +0100
committerDavid Mitchell <davem@iabyn.com>2013-04-24 16:40:15 +0100
commita453e28ae209e82ef2533e2e2bfe25490fd60654 (patch)
tree09fa23d3eb05b5f03e5b0c09b936b0ec5389ce26 /pod/perlsub.pod
parent5fbe83117ea59ccad42477c465113c7550a3675d (diff)
downloadperl-a453e28ae209e82ef2533e2e2bfe25490fd60654.tar.gz
make qr/(?{ __SUB__ })/ safe
(See RT #113928) Formerly, __SUB__ within a code block within a qr// returned a pointer to the "hidden" anon CV that implements the qr// closure. Since this was never designed to be called directly, it would SEGV if you tried. The easiest way to make this safe is to skip any CXt_SUB frames that are marked as CXp_SUB_RE: i.e. skip any subs that are there just to execute code blocks. For a qr//, this means that we return the sub which the pattern match is embedded in. Also, document the behaviour of __SUB__ within code blocks as being subject to change. It could be argued for example that in these cases it should return undef. But with the 5.18.0 release a month or two away, just make it safe for now, and revisit the semantics later if necessary.
Diffstat (limited to 'pod/perlsub.pod')
-rw-r--r--pod/perlsub.pod3
1 files changed, 3 insertions, 0 deletions
diff --git a/pod/perlsub.pod b/pod/perlsub.pod
index 87d45d30ac..027d7bea36 100644
--- a/pod/perlsub.pod
+++ b/pod/perlsub.pod
@@ -232,6 +232,9 @@ your subroutine's name.
return($x * __SUB__->( $x - 1 ) );
};
+The behaviour of C<__SUB__> within a regex code block (such as C</(?{...})/>)
+is subject to change.
+
Subroutines whose names are in all upper case are reserved to the Perl
core, as are modules whose names are in all lower case. A subroutine in
all capitals is a loosely-held convention meaning it will be called