Re: perl "alternating foreach" feature idea
- From: "Jürgen Exner" <jurgenex@xxxxxxxxxxx>
- Date: Sun, 25 Feb 2007 16:26:42 GMT
Erik 2.0 wrote:
dear perl people,
in the spirit of both perl's brevity and it's "do what i mean" array
contexts, it would be an appropriate feature for foreach loops to
support an array of variables as the iterator as well as just a
scalar. this would cause perl to alternate across the array:
for example:
foreach ($key, $val) in (@pairs) {
print "$key=$val\n";
}
This looks like a poor design of your data structure. If you sequence has
alternating elements of identifiers (aka keys) and values, then an AoA seems
to be a much more natural way to represent this data.
And iterating over an array that contains just the references to the data
pairs works beautifully with the existing Perl features as of today.
this syntax for an "alternating foreach" seems quite elegant to me.
Well, but your data structure is anything but.
jue
.
- References:
- perl "alternating foreach" feature idea
- From: Erik 2.0
- perl "alternating foreach" feature idea
- Prev by Date: Re: perl "alternating foreach" feature idea
- Next by Date: trapping a manual close signal
- Previous by thread: Re: perl "alternating foreach" feature idea
- Next by thread: Re: perl "alternating foreach" feature idea
- Index(es):
Relevant Pages
|