Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: help with

by HyperZonk (Friar)
on Jul 27, 2001 at 07:19 UTC ( [id://100219]=note: print w/replies, xml ) Need Help??


in reply to Re: help with
in thread help with the diamond operator

The code you offer is certainly clearer to an individual who has perhaps first started writing in Perl, coming from another language, but I have to quibble with your statement that "it's best."

Part of learning a new language is learning its idioms. The implicit $_ is probably one of the most widely used idioms in Perl, and appears in almost every well-written script. By encouraging a new programmer to "pass by" that idiom, I think you make it less likely that the person will learn its use.

I would say that it is actually "best to say" what the new programmer will have to learn to program efficiently and to read scripts by other programmers. After all, particularly in this case, the implicit $_ is not a difficult concept. If the new programmer doesn't learn it here, then learning grep and map will only be that much more difficult.

As for the argument that one may introduce bugs if one starts using things like grep, it only becomes that much more likely that a programmer who is unfamiliar with the implicit $_ will make such errors if you try to "hide" its use from him/her in simpler structures.

-HZ

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://100219]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-16 09:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found