We don't bite newbies here... much PerlMonks

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.
```

Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (14)
As of 2016-05-02 14:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
What font do you use for programming?

Results (41 votes). Check out past polls.