|Just another Perl shrine|
Perl::Critic says don't modify $_ in list functions and other thingsby Lady_Aleena (Curate)
|on Jul 09, 2020 at 01:29 UTC||Need Help??|
Lady_Aleena has asked for the wisdom of the Perl Monks concerning the following question:
Hello all. I have been playing around with Per::Critic on the command line and found to my dismay that some of my modules do not pass gentle. I realize that I can ignore the recommendations of Perl critic, but I would love for my modules to pass "gentle" before I begin ignoring things.
The most common issue is that I modify $_ in list functions. The following is a convenient and short one liner to put the lines of files into a list. I thought doing it this way was nice and slim.
In one subroutine, I have this three times.
Also, my idify subroutine is just modifying $_.
And my Fancy::Map modifies $_ too.
If this is something ignored usually, I will ignore it, but I would like to know how to make it better. Should I just assign $_ to a variable and then use the variable?
Another thing that I am confused by is why the expression form of eval is discouraged?
The rest of the gentle issues are me being lazy with conditionals. While writing I was thinking my $var = "foo" if 'some condition', but Perl critic does not like it, but it is fixed easily.
NOTE: Please see my update. Most are fixed, but the eval problem remains.
My OS is Debian 10 (Buster); my perl versions are 5.28.1 local and 5.8.8 on web host.
No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!