Ingo Blechschmidt skribis 2005-09-21 14:47 (+0000):
> my $pair = (a => 42);
> say ~$pair; # "a\t42"? "a\t42\n"? "a 42"?
> say +$pair; # 0 (pairs aren't numbers)?
> # 42?
> # 0 ("a" is not a number)?
> # 0 (~$pair can't be used as a number)?
> say ?$pair; # true (because 42 is true)?
> # true (because pairs are always true)?
> FWIW, I'd opt for ~$pair to be "a\t42", +$pair to be +(~$pair) [1],
> and ?$pair to be always true.
Pairs are objects, thus references.
I like your suggestions for ~$pair (though any separator except other \s
characters would do) and ?$pair.
I don't think +(~$pair) makes any sense, though. It's basically the same
as +(~$pair.key). It's probably wise to avoid that $pair can be confused
for its key or value. A good alternative is hard to find, though. I tend
to prefer 1 at this moment (coincidentally, that's +?$pair).
Juerd
--
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html
http://convolution.nl/gajigu_juerd_n.html