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", $X[$j]);
     }
     printf ( "\n");
  }
When I execute, I get
   1      11      21
   2      12      22
   3      13      23
   4      14      24
   5      15      25
   6      16      26
   7      17      27
   8      18      28
   9      19      29
  10      20      30

Any comment on this welcome.

Regards
Guruguhan


-----Original Message-----
From: N, Guruguhan (GEAE, Foreign National, EACOE) 
Sent: Friday, June 18, 2004 5:08 PM
To: [EMAIL PROTECTED]
Subject: printing array elements in columns


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?

TIA
Guruguhan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to