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

Re: can understand one line of code

by BrowserUk (Pope)
on Dec 19, 2012 at 15:24 UTC ( #1009577=note: print w/replies, xml ) Need Help??

in reply to can understand one line of code

Break it down:

  1. grep( expression, @{ ... } )
  2. The expression  s#$#$RegObj->{DELIM}#

    start with 's', so it is a substitution.

    The #s are delimiters so the two sides are: $ and $RegObj->{DELIM}

    So it is substituting the module defined delimiter for any '$'s every end of line.

  3. The array: @{ $RegObj->{MEMBERS}= [ @{$RegObj->{SUBKEYS}} ] }

    Contains an assignment: $RegObj->{MEMBERS}= [ @{$RegObj->{SUBKEYS}} ]

    It copies the array of subkeys : @{ $RegObj->{SUBKEYS} } into an anonymous array [ ... ]

    And assigns its reference to $RegObj->{MEMBERS} = ...

    Then it dereferences that to supply the subkeys to grep.

Thus, that one line is equivalent to:

my @temp = @{ $RegObj->{SUBKEYS} }; $RegObj->{MEMBERS} = \@temp; grep s[$][$RegObj->{DELIM}], @temp;

Without the need for @temp; but less efficient.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009577]
[talexb]: Corion I admired the pool .. I wasn't .. soaking in it. ;)
[talexb]: Plus, I've been awy from PM for about three weeks .. needed a bit of catch-up time.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2017-07-20 15:16 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (304 votes). Check out past polls.