Re: printing array elements in columns

2004-06-21 Thread Zeus Odin
"Guruguhan N" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi All, Hello. Please read Charles K. Clarkson's comments. They are spot on. I will not repeat them here. > In reply to my own posting, I have written a code like the one given below. > @X = (1 .. 30) > $n_el = scala

RE: printing array elements in columns

2004-06-21 Thread Charles K. Clarkson
N, Guruguhan (GEAE, Foreign National, EACOE) <> wrote: : In reply to my own posting, I have written a code : like the one given below. : : @X = (1 .. 30); : : $n_el = scalar(@X); : $n_row = $n_el/3; # 3 is the number of columns I want. : : for ($i=0; $i<$n_row; $i++) { : f

RE: printing array elements in columns

2004-06-21 Thread N, Guruguhan \(GEAE, Foreign National, EACOE\)
Hi All, In reply to my own posting, I have written a code like the one given below. Let @X = (1 .. 30) $n_el = scalar(@X); $n_row = $n_el/3; # 3 is the number of columns I want. for ($i=0; $i<$n_row; $i++) { for ( $j=$i; $j <$n_el; $j+=$n_row) { printf ( "%4d\t

RE: printing array elements in columns

2004-06-18 Thread Bob Showalter
N, Guruguhan (GEAE, Foreign National, EACOE) wrote: > Hi All, > I have a one dimensional array @X, containing N elements. I > would like to know how I can print this N elements in M columns? If you want the data to read across, then down, you can do: @X = 'A' .. 'Z'; $m = 8; p

RE: printing array elements in columns

2004-06-18 Thread Tim Johnson
I can't test this out where I am, but here's one thought... ## my $columns = 5; my $i = 0; while($i < ($#X + $columns)){ for($i..$i+$columns){ print $X[$_]; for(1..(20 - length($X[$_])){ print " "; } } print "\n"; } -O

Re: printing array elements in columns

2004-06-18 Thread Edward Wijaya
On Fri, 18 Jun 2004 17:08:08 +0530, N, Guruguhan (GEAE, Foreign National, EACOE) <[EMAIL PROTECTED]> wrote: Hi All, I have a one dimensional array @X, containing N elements. I would like to know how I can print this N elements in M columns? print join("\n", @X), "\n"; Or if you hav