[Koha-devel] koha code cleaning bug?
Joe Atzberger
ohiocore at gmail.com
Mon Sep 29 18:43:52 CEST 2008
On Mon, Sep 29, 2008 at 11:03 AM, Galen Charlton <galen.charlton at liblime.com
> wrote:
> Hi,
>
> On Mon, Sep 29, 2008 at 9:42 AM, Marc Chantreux
> <marc.chantreux at biblibre.com> wrote:
> > do you think that:
> >
> > for my $var ( list_generator ) {
> > $var =~ /useless/;
> > $var =~ s/old/new/;
> > next unless -d $var;
> > mkdir $_;
> > }
> >
> > is more readable than:
> >
> > for ( list_generator ) {
> > /useless/;
> > s/old/new/;
> > next unless -d;
> > mkdir $_;
> > }
>
> I do. :)
I don't. I actually prefer the latter. And if you construct the example
more conventionally, it should be obvious what the topic is without any
explanatory comment.
foreach (@directories) {
...
}
> > I think that be confortable with $_ (without abusing it) is a part of
> > the perl programmer skills set. If you don't, you'll never use such
> > usefull fonctions like grep and map.
>
> I agree that a Perl programmer ought to know how to use $_. However,
> IMO the project needs to accept contributions from both expert and
> novice Perl programmers, and too much use of "punctuation" variables
> outside of the while (<FILE>) idiom reduces clarity.
I don't consider $_ at all an "advanced" construction. It's proper use
should be common, certainly more common than other punctuation vars. On
that note though, I don't see anything wrong with $! or $. either. I'd much
prefer $. to $NR! Feel free to use $INPUT_LINE_NUMBER if you want, but that
level of $VERBOSITY seems a bit too remedial for common usage.
Case in point though, here I agree it is better to add a variable rather
than assign to $_. But more broadly, coding to avoid $_ altogether is
working against the language unnecessarily and, imho, unproductively.
-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-devel/attachments/20080929/c5555a1c/attachment-0003.htm>
More information about the Koha-devel
mailing list