Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 about the Monastery: (7)
As of 2014-07-24 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (160 votes), past polls