From 73e5543177f354554a06259ef5032a4a7b21ed94 Mon Sep 17 00:00:00 2001 From: Ricardo Signes Date: Thu, 25 Sep 2025 10:39:21 -0400 Subject: [PATCH] perlsub: correct pre-postderef language about "starts with" It's no longer correct that `\%` means "must start with %", because it could instead end with ->%* -- and in fact one of the examples already showed that! I also replaced the list of declarators with "my and others", to keep it more futureproof. "state", for example, had been omitted. --- pod/perlsub.pod | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/pod/perlsub.pod b/pod/perlsub.pod index b9d527344f75..595c0b3953d1 100644 --- a/pod/perlsub.pod +++ b/pod/perlsub.pod @@ -1523,10 +1523,21 @@ corresponding built-in. sub mytime () mytime Any backslashed prototype character represents an actual argument -that must start with that character (optionally preceded by C, -C or C), with the exception of C<$>, which will -accept any scalar lvalue expression, such as C<$foo = 7> or -C<< my_function()->[0] >>. The value passed as part of C<@_> will be a +really using that character for type, with the exception of C<$>, which will +accept any scalar lvalue expression, such as C<$foo = 7> or C<< +my_function()->[0] >>. "Using that character for type" means that the +expression I with the sigil (optionally preceded by a declarator like +C) or I with the sigil's postfix dereference form. Any of these, for +example, satisfies C<\%>: + + %hash + %$hashref + my %hash + $hashref->%* + %{ expr } + (expr)->*% + +The value passed as part of C<@_> will be a reference to the actual argument given in the subroutine call, obtained by applying C<\> to that argument.