develooper Front page | perl.perl5.porters | Postings from June 2021

Re: RFC: Multiple-alias syntax for for

Thread Previous | Thread Next
From:
=?UTF-8?Q?Branislav_Zahradn=C3=ADk?=
Date:
June 22, 2021 15:20
Subject:
Re: RFC: Multiple-alias syntax for for
Message ID:
CAB=rbOnAW3WvSM8ZS7nGeDiQP7_mvUr2R7L9EGdSUuXGtP1SXA@mail.gmail.com
On Tue, 22 Jun 2021 at 17:04, Dave Mitchell <davem@iabyn.com> wrote:

> On Tue, Jun 08, 2021 at 11:20:57AM +0000, Nicholas Clark wrote:
>
> So given:
>
>     @a = (1,2,3,4,5); @b = (11,22,33,44,55); @c = (111,222,333,444,555);
>
> consider
>
>     for my ($x, $y, $z) (@a; @b; @c) { print "($x,$y,$z) " }
>     # outputs (1,11,111) (2,22,222) ... (5,55,555)
>
>
>
You can expand this idea with loop similar to Java for-each loops
and/or mix multi-alias iterators (using colon as iterator bind operator,
just to provide some kind of example)
for my ($x, $y1, $y2, $z1, $z2) ($x : (8, @a); ($y1, $y2) : %b; ($z1, $z2)
: @c)

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About