> From: Christopher Redinger <[EMAIL PROTECTED]>
>
> Sorry it took so long to reply Sean. I tried my best to get through this
> in the morning, but I hadn't had my coffee yet. Then, I got involved in
> work, and forgot about it.
>
> On 09 Jul 2001 10:43:52 -0400, Sean Quinlan wrote:
> > the problem line to:
> > my %params = @_ or ();
>
> I don't think you really solved the problem you were trying to solve
> here. Really, you have introduced an error.
>
> || evaluates its left argument as a scalar. So really, your code was
> being evaluated as:
> my %params = scalar(@_) || ();
> scalar(@_) was evaluating to 2.
> you were effectively saying my %params = 2.
> Which is clearly not what you intended.
D'oh!!! And I might have caught this and saved some embarasment, if only I had
thought to change the debug value to _any_ other value but 2! :-|
>
> So, what did your "fix" do?
> my %params = @_ or ();
> Well, or has a higher precedence than assignment. Which means now you
> are saying:
> (my %params = @_) or ();
> Sure, it works for you when @_ contains something, but it's not really
> doing exactly what you want. (Okay, technically it DWYM because %params
> is empty anyways, but ignore that for the sake of letting me finish.
> Imagine () is some list that you really wanted it to default to, like
> ('foo', 'bar')).
>
> What you really wanted would have been:
> my %params = @_ ? @_ : ();
> Which, while ugly, should give you the default values if you had done
> something other than ().
And so is certainly the better choice for this, thanks!
--------------------------
Sean Quinlan
mailto:[EMAIL PROTECTED]
http://bmerc-www.bu.edu/
"You can discover more about a person in an hour of play than in a year of
conversation" - Plato