Why is it that this runs:
$ perl -e 'for $a (1..2){for $b (10..12){print "$a-$b\n"}}'
1-10
1-11
1-12
2-10
2-11
2-12
and this runs:
$ perl -e 'for $a (1..2){print "$a-$_\n" for (10..12)}'
1-10
1-11
1-12
2-10
2-11
2-12
but this crashes with a syntax error:
$ perl -e 'for $a (1..2){print "$a-$b\n" for $b (10..20)}'
syntax error at -e line 1, near "$b ("
Execution of -e aborted due to compilation errors.
in Perl v5.10.1.
Thanks for your time!
Tel2
In reply to Syntax error with nested for loop by tel2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |