Rob Dixon wrote:
> Wiggins D Anconia wrote:
> >
> > > Tom Kinzer wrote:
> > > >
> > > > as a matter of style, i think always having them is nice for
> > > > maintenance/readability.
> > >
> > > I may be wrong, but I think most Perl programmers would disagree.
> > >
> > > It may be nice for maintenance if your program is to be maintained
> > > by a herd of Prolog programmers, but readability is certainly
> > > reduced by redundant punctuation.
> > >
> > > while (<>) { print unless /^#/ }
> > >
> >
> > Yeh, and the "that's two extra characters to type" police will get you
> > too, not that I have been deputized into their gang. I don't like their
> > mascot, $_, anyways....
>
> Hi Wiggins.
>
> Not sure which way you're leaning here. I never saw you as anti the 'it'
> variable $_?
>
> Rob
I think its a matter of context, Rob. What I cringe at is seeing a default
variable being used in dense code. The more other code happening, the less
clear will be the meaning of $_. When I first started using Perl, I just
didn't like it a bit--it seemed just too damned tech-ish. I've come to
appreciate, though, that it can be very effective and actually aid clarity in
a more staccato context. I would say that it should be used only in contexts
where it is very clear what it means:
foreach (@lines) {
chomp;
s/dog/cat/g;
my @words = split;
$words[0] = lc $words[0];
$_ = join ' ', reverse @words;
print ucfirst $_, "\n";
}
While the purpose of the above may bve totally incomprehesible, there is no
question about what $_ is. <;:-o)
Joseph
__DATA__
The dog bit the cat
Every dog has it's day
The dogs of war have gathered for their feast
My dogs better than your dog
^Z
Cat the bit cat the
Day it's has cat every
Feast their for gathered have war of cats the
Cat your than better cats my
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>