24 Jul 2022 06:28:31 UTC
- Distribution: Perl-Critic-Community
- Module version: v1.0.3
- Source (raw)
- Browse (raw)
- How to Contribute
- KwaliteeBus factor: 1
- 89.40% Coverage
- License: artistic_2
- Perl: v5.10.1
- Activity24 month
- Download (46.32KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:2 non-PAUSE usersDBOOK Dan Book
- Reverse dependencies
- CPAN Testers List
- Dependency graph
Perl::Critic::Policy::Community::AmpersandSubCalls - Don't use & to call subroutines
&) were once needed to call subroutines, but in modern Perl they are not only unnecessary but actually change the behavior from what you may expect. Calling a subroutine with an ampersand ignores the subroutine's prototype if any, which may change what arguments the subroutine receives. Additionally, calling a subroutine as
&foo;with no arguments will pass on the contents of
@_from the current subroutine, which may be quite surprising. Unless used intentionally for this behavior, the ampersand should simply be omitted.
my $value = &foo(); # not ok my $sum = &foo(1,2); # not ok my $value = foo(); # ok my $sum = foo 1,2; # ok
This policy is a subclass of the core policy Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils, and performs the same function but in the
This policy is part of Perl::Critic::Community.
This policy is not configurable except for the standard options.
Copyright 2015, Dan Book.
This library is free software; you may redistribute it and/or modify it under the terms of the Artistic License version 2.0.
Module Install Instructions
To install Perl::Critic::Community, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Perl::Critic::Community
For more information on module installation, please visit the detailed CPAN module installation guide.