Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Extracting elements from array

by GrandFather (Saint)
on Jan 15, 2016 at 19:38 UTC ( [id://1152890]=note: print w/replies, xml ) Need Help??


in reply to Re: Extracting elements from array
in thread Extracting elements from array

However

my @newArray = grep {exists $_->{name}} @$aref;

seems a lot cleaner and easier to maintain than the version you offered. Is grep really that much more arcane than using if as a statement modifier, a superfluous statement label and redundant {} when dereferencing a simple array reference?

Premature optimization is the root of all job security

Replies are listed 'Best First'.
Re^3: Extracting elements from array
by 1nickt (Canon) on Jan 15, 2016 at 20:24 UTC

    dereferencing a simple array reference

    I always dereference with curly braces, AND whitespace! Sure, it's redundant, but it allows my tired old eyes to see what I just wrote.

    keys %$href
    keys %{ $href }
    I have to squint a little to read the former; not so much on this page, but on the terminal, definitely. :-( But to each their own, eh?

    The way forward always starts with a minimal test.

      When you read English prose like :

      He (Tom) ...

      where do you expect to see white space ? Why should your expectations be different for other languages ( even artificial ones ) ?

      You have been trained since your first exposure to printed English to very standardised use of white space . Are you suggesting we should throw away all that hard wired preprocessing and reinvent a whole ' nother wheel ? Have you even tried typing prose with " silly " white space ? It ' s actually quite slow because it ' s not at all " natural ". What ' s it like to read ? Do ( ( redundant ) ) or ( unnecessary ) brackets help ?

      Premature optimization is the root of all job security

        Well, besides the eyesight issue, there's the fact that I wasn't actually trained that way in Perl.

        When I started at the University of RTFM I was looking at a lot of very ugly code. Lots of global vars up top, massive chunks of comments, lots of repeated lines to populate data, lots of report()/write() sections ... all the glories of Perl 4, Matt's Script Archive; it was ugly.

        The first thing I used to do (and still do) was to put in a bunch of blank lines and spaces so I could see what was going on. I got used to writing that way, and maybe because of that, as you say, and maybe because it's intrinsically clearer, I find it it much easier to take in paragraphs of code at a time.

        YMMV :-)

        The way forward always starts with a minimal test.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-29 07:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found