Thakur has asked for the wisdom of the Perl Monks concerning the following question:
I want my subroutine to calculate the tables of 2,3,4 and display them in separate lines.I made a subroutine called "table" and passed 2,3,4 as parameter.But I am getting the table of 2 only and not 3 and 4.Below is my code.Please check and let me know.
use strict; use warnings; use diagnostics; use 5.01000; &table(2,3,4); sub table{ my $i = 1; my $loop; foreach $loop(@_){ for($i;$i<=10;$i++){ my $ans = $i*$loop; print"$ans "; } print"\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help me
by Anonymous Monk on Jan 15, 2012 at 09:41 UTC | |
|
Re: Help me
by ansh batra (Friar) on Jan 15, 2012 at 09:32 UTC | |
by Thakur (Acolyte) on Jan 15, 2012 at 09:38 UTC | |
|
Re: subroutine to calculate multiplication tables
by CountZero (Bishop) on Jan 15, 2012 at 13:47 UTC | |
|
Re: subroutine to calculate multiplication tables
by Anonymous Monk on Jan 15, 2012 at 15:31 UTC |