Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggested policy: named loop variable #1062

Open
epa opened this issue Apr 10, 2024 · 0 comments
Open

Suggested policy: named loop variable #1062

epa opened this issue Apr 10, 2024 · 0 comments

Comments

@epa
Copy link

epa commented Apr 10, 2024

Inexperienced Perl programmers may write something like

foreach (@things) {
    my $thing = $_;
    do_something($thing);
}

Perlcritic could suggest using $thing as the iterator variable instead. (Let's say if the assignment is the first thing in the loop body and isn't mutated, and $_ is not later used within the loop. That last requirement is quite hard to check for, so this policy may not be practical to implement.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant