we've just been discussing the idea of a 'style' pragma that warns when you use $_ instead of a named variable, use map/grep for side effects or other nasty perl abuse.
then you could have:
.. nice code ..
NASTY: {
.. nasty code ..
}
use style;
use no style;
How cool would that be ?
Re:the underscore thing was already implemented
davorg on 2003-02-25T17:26:24
Underscore.pm (named so it could be invoked with no Underscore) is a demonstration of tieing scalars in chapter 14 of Programming Perl (3ed).
Doesn't seem to have made it to CPAN yet tho'
:) Re:the underscore thing was already implemented
TeeJay on 2003-02-25T17:34:53
cool!if only I had 3rd edition instead of 2nd..
anyone know where I can get some pointers or a how to on building and implementing a perl pragma or language filter ?
Re:style sucks
TeeJay on 2003-02-25T17:23:51
I think it would be useful in a lot of areas, particularly where you have a company coding standard.I have worked to coding standards a few times and have never really had any complaints apart from the shocking hoops required to implement anything useful in asp/vbscript.
Admittedly, the $_ is invisible in most such examples, but that doesn't mean it isn't there.given $foo {
.bar;
.baz;
.quux;
}
$_
with use of map()
and grep()
in void context? To me, writing Perl without $_
is like writing English without pronouns. It's hardly a mark of good style.
Re:Underscore
TeeJay on 2003-02-28T09:04:33
I mean, often I see $_ used and modified 5 times in a dozen lines, this is a pig when a program has evolved over time - named variables are usually preferably 9 times out of 10.