Right it can either stop as the shortest list iteration is done, or just set
the corresponding alias to undef.
Don't really know which would be more helpful, since I first need to find a
scenerio where I would use this facility, then what result would I expect
once the shortest list runs out. Do I still need the values of the longer
list, for one reason or another, or do I want the loop aborted?
Ilya
-----Original Message-----
From: David L. Nicol
To: Sterin, Ilya
Cc: 'raptor '; '[EMAIL PROTECTED] '
Sent: 07/20/2001 1:44 PM
Subject: Re: array/hash manipulation [was :what's with 'with'?]
"Sterin, Ilya" wrote:
>
> Hmmm. Didn't think about that. That would be a nice way, that way you
can
> manipulate it's behaviour depending with how many aliases you provide.
>
> for my $el1, $el2 ( (@foo, @bar) ) {
> print "$el\n"
> }
>
> $el1 and $el2 would of course be aliases, right?
>
> But one though might be, what happens if this is written...
>
> for my $el1, $el2 ( (@foo, @bar, @arr) ) {
> print "$el\n"
> }
>
> Does this bahave in the same way as the first one, but we just don't
set
> @arr elements, since the user forgot to provide a third alias, or
should
> this croak at compile time?
>
> Ilya
Given your definition of
for [list of variables] ([comma-listed arrays]) {...}
I'd consider anything less than a full crash and burn if the number of
variables and the number of arrays did not match to be dangerous. If
you
want @bar and @arr combined, you could present them as
for $fooelem, $bar_arr_elem (@foo, (@bar, @arr)) { ...
I would also expect this to stop as soon as the shortest list is out
of elements; also to take other kinds of generators besides
preconstucted
lists in there as the arrays, making the syntax
for [list of N variables] ([list of N generators]) {...}
--
David Nicol 816.235.1187
"Mary had a little chainsaw" -- Angus Oblong