in reply to Re: foreach loop and creating files with "$_"
in thread foreach loop and creating files with "$_"
a lot of people find $_ ugly and even obfuscatory.
Possibly true, but then they are people who don’t know and use Perl! Perl is, by design, an atypical language, so its idioms and byways are often unintuitive at first, but unfamiliar should never be mistaken for ugly. As apotheon notes, people who find Perlish idioms ugly sometimes avoid Perl itself for that reason. IMHO that is not necessarily a bad thing.
I concur. And I'll submit that $_ is actually quite intuitive -- it's just other programming languages that are unintuitive, unfamiliar and (arguably) unnatural in this regard.
For me, $_ is simply the current topic that's being talked about. Like in natural languages, sometimes you leave it out entirely, since it's clear from the context what's being meant; sometimes you merely say "this" or "it" (which is how I read $_). Perl doesn't go quite as far as natural languages where you can have several of these at once, but on the other hand, unlike natural languages, Perl cannot afford to be ambiguous ("Bill met Bob. They talked, and he gave him back the book" is fine; the same thing in Perl wouldn't be).
Still, having one "topic" is better than having none, as most programming languages do. Natural languages are intuitive, after all, and we're all familiar with them.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: foreach loop and creating files with "$_"
by xiaoyafeng (Deacon) on Jul 22, 2014 at 09:26 UTC | |
by AppleFritter (Vicar) on Jul 22, 2014 at 11:02 UTC |