in reply to Parameter list wierdness

This one took some fiddling for it to occur to me what was the problem.

Trinary operators can be used as an R-value, or as an L-value. You've constructed a L-value.

Here's what's happening:
ref($_[0]) ? $params = shift : $params = {@_};

When the trinary's conditional is false (no reference), {@_} is assigned to $params. When the trinary's conditional is true, {@_} is assigned to $params = shift. Though the following behavior is undefined, here's why "it" doesn't work. $params = shift shifts the reference out of @_. But then next a hash reference is created using the now empty @_ with the " = {@_} " part. So the first value of $params is discarded, and replaced by a hash-ref to a hash containing only the empty array @_.

There's some speculation in all that, but it seems to bear out in lightweight testing.


Dave