From: Steve Hancock Date: Wed, 3 Jan 2024 16:29:36 +0000 (-0800) Subject: add example to docs X-Git-Tag: 20230912.12~17 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=532f8c9398b4f83ccb6fc8272c9195bb35a30fc1;p=perltidy.git add example to docs --- diff --git a/bin/perltidy b/bin/perltidy index 8b697102..f2dc249f 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -5561,15 +5561,24 @@ order skip temporary package changes. =item B -These are variables which occur just one time in their scope in the program -text. Calling them B is convenient but not really accurate. There -are many reasons for having such variables. For example, they might occur in a -list of values provided by another routine or data structure, and therefor must -be listed, even though they might not be referenced again. Or they might be -defined for possible future program development, clarity or debugging. But -sometimes they can occur due to being orphaned by a coding change, due to a -misspelling, or by having an unintentional preceding C. So it is worth -reviewing them, especially for new code. +These are variables which are declared with a C and not referenced again +within their scope. Calling them B is convenient but not really +accurate. There are many reasons for having such variables. For example, they +might occur in a list of values provided by another routine or data structure, +and therefor must be listed, even though they might not be referenced again. Or +they might be defined for possible future program development, clarity or +debugging. But sometimes they can occur due to being orphaned by a coding +change, due to a misspelling, or by having an unintentional preceding C. +So it is worth reviewing them, especially for new code. Here is a simple +example of an error in an old script found with this method: + + BEGIN { my $string = "" } + ... + $string .= "ok:"; + +It looks nice, but the C declaration in braces is reported as unused since +its scope is limited by the braces. This would have also been caught by perl +if the author had used C. =back