On Mar 1, Jon Molin said: >I've always thought there's a difference between for and foreach, that >for uses copies and foreach not. But there's no diff is there?
>From perlsyn, "Foreach Loops": The foreach keyword is actually a synonym for the for keyword, so you can use foreach for readability or for for brevity. >why isn't it possible to write: >$b += 2 for my $b (@a); > >but possible to write >for my $b (@a) {$b += 2}; All the expression modifiers are designed that way: if EXPR unless EXPR while EXPR until EXPR foreach EXPR It has to be an expression -- that means you can't say: print $i for ($i = 0; $i < 10; $i++); And if you decided to leave off the parens... it would have a surprising result. ;) -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]