in reply to Perl::Critic policy to catch quoted execution?

Since such method calls do not do anything like what one might naively expect, I'm not sure a Perl::Critic policy would be useful:

Win8 Strawberry 5.8.9.5 (32) Thu 09/22/2022 13:05:47 C:\@Work\Perl\monks >perl use strict; use warnings; my $ref = sub { return "hiya \n"; }; print $ref->(); my $str = "foo $ref->() bar \n"; print $str; ^Z hiya foo CODE(0x9145ec)->() bar
What criticism would you expect in this case? Isn't the fact that something's wrong going to be immediately obvious?


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: Perl::Critic policy to catch quoted execution?
by Your Mother (Archbishop) on Sep 22, 2022 at 17:29 UTC

    Obvious is in the eye of the beholder. I’ve seen this class of error make it into production in two workplaces. Update: for criticism, just to flag it exactly as you say: “This won’t output what you seem to expect.”