On Mon, Jan 21, 2002 at 12:51:39PM -0500, Bernie Cosell wrote:
> On 21 Jan 2002, at 17:00, Robin Houston wrote:
>
> > On Mon, Jan 21, 2002 at 11:38:52AM -0500, Bernie Cosell wrote:
> > > First, it is an *assignment* [at least to my eye], and so any solution
> > > that doesn't begin with "undef %a" isn't going to have 'join' semantics
> >
> > I think you must have missed the first line of my code:
> >
> > %a = (%b, %c);
>
> You're right. my apologies, and I agree --- your code does do an outer
> join. I got down the wrong path partly because my default intuition
> [from what I typically waht to do when I mess with SQL dbs] is that I was
> thinking _inner_ join and then misread your code...
>
> Maybe if '^' is going to apply to hashes, there'll have to be two
> different operators, one for the 'inner' sense of the operation and the
> other for the 'outer'....
What makes you think this "problem" will only occur with hashes?
Consider:
@a = 1, 2, 3;
@b = 1, 2, 3, 4, 5;
@c = @a ^+ @b;
print scalar @c, "\n";
It should print `3' or `5', depending on one's "inner join" or
"outer join" preference.
IMO, the most Perlesque approach would be the "outer join" style -
missing elements will be filled in by Perl, with an appropriate
value, typically undef (which would become 0 in numerical context).
Abigail