-
Useless Use of $_
2004-09-23 20:58 in /tech/perl/HallOfShame
A new feature — my Perl Hall of Shame, featuring occasional snippets of perl code that someone actually wrote. Today, a little pattern I’ll call “useless use of $_”:
for ( 0..9 ) { my $i = $_; for ( 0..9 ) { my $j = $_; ... } }I think that perhaps the author of this was trying to avoid polluting the enclosing lexical scope with his loop variables, but wasn’t aware that exactly the same thing can be achieved without resorting to punctuation variables:
for my $i ( 0..9 ) { for my $j ( 0..9 ) { ... } }
Leave a comment
Please use plain text only. No HTML tags are allowed.
Comments are closed for this story.
Trackbacks are closed for this story.