On 21 Jan 2002, at 15:12, Simon Cozens wrote:
> On Mon, Jan 21, 2002 at 03:00:57PM +0000, Robin Houston wrote:
> > In an ideal world it would behave the same as
> > %a = (%b, %c);
> > for my $k (keys %a) {
> > $a{$k} += $b{$k} if exists($b{$k}) && exists($c{$k});
> > }
>
> It's not impossible that it would end up doing just that.
Is that right? --- that is, add b to a on condition of c, but the actual
value from the c hash isn't used at all, and a is *incremented* even
though it looks like an assignement [you removed it from your followup,
but I think the original was:
%a = %b ^+ %c
That's *REALLY unintuitive [at least to me] to have it work with the
above semantics.
I hadn't heard of it before, but I got the impression taht '^' was going
to be like a vector operation, and so you'd have
%a = %b ^+ %c
as being like:
undef %a ;
for my $k (keys %b)
{ $a{$k} = $b{k} + $c{k} if exists $c{k} ; }
[this being a sort of inner-join, and if you like you could have
something like an outer-join, where the non-exists element of the other
hash would be treated as a '0'.]
Did I misunderstand what '^' is supposed to do? [I thought that the
original example, @a = @b ^+ @c did an element-by-element add of b to c,
was that not right?]
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
mailto:[EMAIL PROTECTED] Pearisburg, VA
--> Too many people, too few sheep <--