declaring lexical variables in shortest scope: performance?by bliako (Prior)
|on Mar 31, 2020 at 10:22 UTC||Need Help??|
bliako has asked for the wisdom of the Perl Monks concerning the following question:
Hello lockdown ones,
Everytime I declare a variable I believe a flop dies in my CPU. Probably because I fell in the C cauldron in my formative years. But now, and in Perl, the paradigm is to "lexicalise" variables within the innermost scope. For example, for:
perlcritic a.pl says Loop iterator is not lexical at line 6, column 1. See page 108 of PBP. (Severity: 5)
But this pacifies perlcritic:
But wakes in me primordial fears of will that variable be created 3 times and decrease performance? (for the sake of readability and, perhaps, stability and not introducing subtle bugs). Does anyone know the difference in performance between the two scripts? Even if it is tiny!