Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Answer: How do I create a matrix?

by jeffa (Bishop)
on Jun 07, 2001 at 12:07 UTC ( #86487=categorized answer: print w/replies, xml ) Need Help??

Q&A > arrays > How do I create a matrix? - Answer contributed by jeffa

Heh, close. :)
The trick is to use an array of array references:
my @matrix = ( [qw(0 0 0 0)], [qw(0 0 1 0)], [qw(0 1 0 0)], [qw(1 0 0 0)], ); foreach my $row (@matrix) { print join(":",@$row), "\n"; } # qw(1 0 0 0) is better way of saying (1,0,0,0)

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2020-10-26 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (249 votes). Check out past polls.

    Notices?