Thanks to visit codestin.com
Credit goes to github.com

Skip to content

foreach multiple vars may not be refaliases #24027

@leonerd

Description

@leonerd

Perl v5.22 introduced refalias foreach vars:

foreach my \@vals ([1], [2,2], [3,3,3]) {
   say "<@vals>";
}

Perl v5.36 introduced multiple foreach vars:

foreach my ($name, $val) (one => [1], two => [2,2], three => [3,3,3]) {
  say "$name: <" . @$val . ">";
}

Unfortunately, the two may not be combined:

use feature qw( refaliasing declared_refs );
foreach my ($name, \@val) (one => [1], two => [2,2], three => [3,3,3]) {
   ...
}
syntax error at - line 2, near ", \"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions