diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-01-23 12:52:12 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-01-23 12:52:12 +0000 |
commit | 0df79f0ce1a641c23eb6b9df44bd792c1c4400e1 (patch) | |
tree | 7eeb514693f4c66d4d35172ca50b468f01c57329 | |
parent | d8574e8f6e1a85ee7a4da7a6e61b6d4f98fbf7ba (diff) | |
download | perl-0df79f0ce1a641c23eb6b9df44bd792c1c4400e1.tar.gz |
document bareword prototype incompatibility
p4raw-id: //depot/perl@4862
-rw-r--r-- | pod/perldelta.pod | 8 | ||||
-rw-r--r-- | pod/perlsub.pod | 16 |
2 files changed, 21 insertions, 3 deletions
diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 04c16a5dae..f99aa3c97f 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -149,6 +149,14 @@ needs to be written with additional parentheses now: The behavior remains unaffected when C<not> is not followed by parentheses. +=item Semantics of bareword prototype C<(*)> have changed + +Arguments prototyped as C<*> will now be visible within the subroutine +as either a simple scalar or as a reference to a typeglob. Perl 5.005 +always coerced simple scalar arguments to a typeglob, which wasn't useful +in situations where the subroutine must distinguish between a simple +scalar and a typeglob. See L<perlsub/Prototypes>. + =back =head2 C Source Incompatibilities diff --git a/pod/perlsub.pod b/pod/perlsub.pod index 416763f6d8..4ec11f99d4 100644 --- a/pod/perlsub.pod +++ b/pod/perlsub.pod @@ -928,11 +928,21 @@ Unbackslashed prototype characters have special meanings. Any unbackslashed C<@> or C<%> eats all remaining arguments, and forces list context. An argument represented by C<$> forces scalar context. An C<&> requires an anonymous subroutine, which, if passed as the first -argument, does not require the C<sub> keyword or a subsequent comma. A -C<*> allows the subroutine to accept a bareword, constant, scalar expression, +argument, does not require the C<sub> keyword or a subsequent comma. + +A C<*> allows the subroutine to accept a bareword, constant, scalar expression, typeglob, or a reference to a typeglob in that slot. The value will be available to the subroutine either as a simple scalar, or (in the latter -two cases) as a reference to the typeglob. +two cases) as a reference to the typeglob. If you wish to always convert +such arguments to a typeglob reference, use Symbol::qualify_to_ref() as +follows: + + use Symbol 'qualify_to_ref'; + + sub foo (*) { + my $fh = qualify_to_ref(shift, caller); + ... + } A semicolon separates mandatory arguments from optional arguments. It is redundant before C<@> or C<%>, which gobble up everything else. |