Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: simple matrix

by Samy_rio (Vicar)
on May 04, 2006 at 04:10 UTC ( [id://547338]=note: print w/replies, xml ) Need Help??


in reply to simple matrix

Hi steverippl, Try this another way,

TIMTOWDI

use strict; use warnings; use Array::Reform; my $a = 1; my $b = 2; my $c = 3; my $d = 4; my $e = 5; my $f = 6; my $g = 7; my $h = 8; my $i = 9; my @matrix; push(@matrix, $a); push(@matrix, $b); push(@matrix, $c); push(@matrix, $d); push(@matrix, $e); push(@matrix, $f); push(@matrix, $g); push(@matrix, $h); push(@matrix, $i); my $rowsize = 3; ####Number of rows for my $row (Array::Reform->reform( $rowsize, \@matrix )){ $,=" "; print @{$row}, "\n"; } __END__ 1 2 3 4 5 6 7 8 9

GrandFather done well.

Updated: instead of pushing value into an array in line by line. Use looping,

push(@matrix, $_) foreach($a, $b, $c, $d, $e, $f, $g, $h, $i);

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://547338]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-03-29 10:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found