467,883 Members | 1,223 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,883 developers. It's quick & easy.

print in a format of matrix

Hi, i am starter in perl and I am having some problems, in the moment. I would like to know how broke this list in a format of matrix, for example..

@list = 111111111111, whose have 12 elements in this format

1 1 1 1
1 1 1 1
1 1 1 1

with 3 lines and 4 columms.

thanks.
Jun 24 '08 #1
  • viewed: 1205
Share:
1 Reply
KevinADC
Expert 2GB
Hi, i am starter in perl and I am having some problems, in the moment. I would like to know how broke this list in a format of matrix, for example..

@list = 111111111111, whose have 12 elements in this format

1 1 1 1
1 1 1 1
1 1 1 1

with 3 lines and 4 columms.

thanks.
One possibility:

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3.  
  4. my @list = qw(1 1 1 1 1 1 1 1 1 1 1 1);
  5.  
  6. for (@list) {
  7.    for (1..4) {
  8.       print shift @list;
  9.    }
  10.    print "\n";
  11. }    
Of course it is very contrived to fit your exact requirements.
Jun 25 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Ronen Kfir | last post: by
3 posts views Thread by Clark Kent | last post: by
reply views Thread by tasukiph | last post: by
Thekid
1 post views Thread by Thekid | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.