Hi Shmuel, May I say: pitty pitty pitty :) As this syntax has logic in it :)
PS: I am familiar with how to use your idea, but still thanks for the quick reply. Chanan On Wed, May 1, 2013 at 11:09 AM, Shmuel Fomberg <[email protected]>wrote: > Hi Chanan. > > On Wed, May 1, 2013 at 5:06 PM, Chanan Berler wrote: > > >> Quick Perl question: Why I can not do something like this? >> my @arr = ((10,20), (100,200), (111,222)); >> >> foreach my ($a,$b) (@arr) >> { >> print "a=$a, b=$b\n"; >> } >> > > Perl just doesn't support this syntax. Your array will be flatted, and > foreach get one variable at a time. > > you can do this: > > my @arr = ([10,20], [100,200], [111,222]); > > foreach my $rec (@arr) > { > my ($a, $b) = @$rec; > print "a=$a, b=$b\n"; > } > > Shmuel. > > _______________________________________________ > Perl mailing list > [email protected] > http://mail.perl.org.il/mailman/listinfo/perl > -- =================== ---- Chanan Berler ---- ===================
_______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
