Re: perl "alternating foreach" feature idea
- From: Sherm Pendley <spamtrap@xxxxxxxxxxx>
- Date: Sun, 25 Feb 2007 05:25:08 -0500
"Erik 2.0" <erik@xxxxxxx> writes:
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";
}
an odd number of values in @pairs would cause an extra iteration with
$val set to undef
Great idea! When you've implemented it, you should send your patch to p5p
to get it integrated with mainline Perl.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
.
- Follow-Ups:
- Re: perl "alternating foreach" feature idea
- From: Brian McCauley
- Re: perl "alternating foreach" feature idea
- References:
- perl "alternating foreach" feature idea
- From: Erik 2.0
- perl "alternating foreach" feature idea
- Prev by Date: perl "alternating foreach" feature idea
- Next by Date: Re: perl "alternating foreach" feature idea
- Previous by thread: perl "alternating foreach" feature idea
- Next by thread: Re: perl "alternating foreach" feature idea
- Index(es):
Relevant Pages
|