Perl has a large number of builtin built-in functions, ; they are described on the perlfunc manpage [Wall 2011]. Perl also has a handful of reserved keywords such as while; they are described on the perlsyn manpage [Wall 2011].
Do not use an identifier for a subroutine that has been reserved for a builtin built-in function or keyword.
Noncompliant Code Example
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
$passwd_required = 1;
# ...
sub authenticate_user {
local $passwd_required;
if (defined $passwd_required) {
print "Please enter a password\n";
# ... get and validate password
} else {
print "No password necessary\n";
}
}
authenticate_user();
|
...
This compliant solution initializes the localized variable to the old value. So , so it correctly prompts the user for a password.
| Code Block | ||||
|---|---|---|---|---|
| ||||
$passwd_required = 1;
# ...
sub authenticate_user {
local $passwd_required = $passwd_required;
if (defined $passwd_required) {
print "Please enter a password\n";
# ... get and validate password
} else {
print "No password necessary\n";
}
}
authenticate_user();
|
...