Skip to content

[EXPERIMENT] Iterating over every N elements in a list #18744

@KES777

Description

@KES777

I would like to do:

my $list = [ key => 'value', k2 => 2, k3 => 3 ];
for my( $key, $value ) ( @$list ) {
   ...
}

I do not want to use hacks listed here

Then I found similar idea at this question

for i,k in ???:
    ...

Notice, how many people are interested in similar question: 2500 votes up, 1 000 000+ views!

But there is also no solution from the box =(

But perl is better it will allow just:

for my( $first, $second, $n ) ( @list ) {
    ...
}

or any number of elements we want, will it? ;-)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions