Multiplication tables: Difference between revisions
→{{header|Perl}}: Removed more magic numbers. Removed shebang line and "use strict", since they're implied. Switched to the statement-modifier form of "foreach" where possible, for readability.
Underscore (talk | contribs) (→{{header|Perl}}: Removed more magic numbers. Removed shebang line and "use strict", since they're implied. Switched to the statement-modifier form of "foreach" where possible, for readability.) |
|||
Line 224:
=={{header|Perl}}==
<lang perl>
our $width = length($max**2) + 1;
printf "%${width}s", $_ foreach 'x|', 1..$max;
▲print "\n---+", "-" x ($max*4), "\n";
foreach my $i (1..$max) {
printf
foreach "$i|", map { $_ >= $i and $_*$i } 1..$max;
print "\n";
}</lang>
Output:
<pre>
x| 1 2 3 4 5 6 7 8 9 10 11 12
|