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

Masem's scratchpad

by Masem (Monsignor)
on Jun 03, 2004 at 14:24 UTC ( #360162=scratchpad: print w/ replies, xml ) Need Help??

for jc:
SCALAR includes CODEREF, GLOBS, and anything else besides
ARRAY and HASH

Argument Precidence Order for merge($a, $b)
( No data is lost from the $a arg, some might be from $b )

left arg ($a) ->   SCALAR     ARRAY              HASH

right arg ($b) V  
SCALAR                $a   join @$a, $b          $a (*)    

ARRAY                 $a   join @$a, @$b         $a (*)

HASH                  $a   join @$a, values %$b  merge (%$a, %$b)


-----

Storage Precidence Order
( Aim to keep most 'complex' elements in place )

left arg ($a) ->   SCALAR     ARRAY              HASH

right arg ($b) V  
SCALAR                $a   join @$a, $b          $a (*)    

ARRAY         join @$b,$a  join @$a, @$b         $a (*)

HASH               $b (*)  $b (*)                merge (%$a, %$b)

-----

Maximize Retainment Order
( Avoid losing any data, may change scalars to arrays, etc)

left arg ($a) ->   SCALAR     ARRAY              HASH

right arg ($b) V  
SCALAR           ($a, $b)   join @$a, $b        %$a + hashify($b)    

ARRAY         join @$b,$a  join @$a, @$b        %$a + hashify(@$b)

HASH    %$b + hashify($a)  %$b + hashify($a)    merge (%$a, %$b)


(*) Possible 'hashification' where a scalar, or each scalar in an array, is added to a hash with key == value == $scalar.  In this case, another merge is called on the existing hash and the new hash.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (22)
As of 2014-12-18 18:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (59 votes), past polls